|
Hi All
i am developing a custom control in which i have to add asp.net controls like radio button , dropdown and other user controls also.
Please tell me any web site where i can find this things .
Also i have to register javascript in that user control
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Are you trying to add dynamically??
If so the following might help, i am using vb.net as language
dim rb as new RadioButton
rb.Text="Click here"
rb.ID= "Whatever"
if you are trying to run this code as part of UC then Me.Controls.Add(rb) will do, else if you are trying to add the control from a page Me."UserControlID".Controls.Add(rb) should do,
Hope this helps
|
|
|
|
|
hi,
i am having a radiobutton list on my page which is getting data from the database and displaying.
now i want to validate whether atleast one of the radiobutton is selected.
so i want a javascipt code to check whether they are checked or not.
i am not so good at javascript and i dont have time to explore also.
i am having a web application.
If anyone knows it,please share it with me.its urgent.
thanks in advance.
swarup
|
|
|
|
|
Hi Swarup
Take this javascript function and regisetr it on submit button.
'RadioButtonList1' is the name of radio button list that will be given by asp at runtime so check the name by viewing the source code of yoor html page
register your script in this way
Button1.Attributes.Add("OnClick", "javascript:Checkthis();");
<br />
<script language="javascript" type="text/javascript"><br />
<br />
function Checkthis()<br />
{<br />
var radiobuttonlist=document.getElementsByName('RadioButtonList1');<br />
var flag=0;<br />
for(var index=0;index<radiobuttonlist.length;index++)<br />
{<br />
if(radiobuttonlist[index].checked)<br />
{<br />
flag=1;<br />
}<br />
}<br />
<br />
if(flag==1)<br />
{<br />
alert("One is checked");<br />
}<br />
else<br />
{<br />
alert('none is checked give error');<br />
}<br />
<br />
}<br />
<br />
<br />
</script><br />
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi,
I have a problem with List(of Double). below is just an example what happens in List(of Double).
Example:
''Say i have a arraylist filled with data
Dim arrlst as new Arraylist
arrlst.add(10.50)
arrlst.add(Nothing)
arrlst.add(0.0)
''Now I am creating a generic type list with data in above arraylist by looping
Dim lst as new List(of Double)
For i as integer = 0 to arrlst.count-1
lst.add(arrlst(i))
Next
Finally when I checked the data in the List
lst(0) = 10.50
lst(1) = 0.0 ''Here there should be Nothing or novalue, Instead it was 0.0
lst(2) = 0.0
The second value lst(1) should be nothing, Intead it becomes 0.0 while Instantiating List object. Then whats the point in using this object for generic types.
Please help me out, I am in a situation to use only List or collection(Generic type) because of our companies new standard.
I would appreciate if you give me a example.
Thanks in advance
Abdul
|
|
|
|
|
Your issue is with the double type. It can not be null. If you switch this to a nullable type then you will get more of the results you are expecting.
Hope that helps.
Ben
|
|
|
|
|
Please let me know. how to switch this to a nullable type.
It would appreciable, if you give a small example.
Thanks
Abdul
|
|
|
|
|
I believe the correct syntax is:
List(Nullable(Of Double))
You should probably do some reading on nullable types before you go into this. There are plenty of articles out there.
Ben
|
|
|
|
|
As per your reply, I have used List(of nullable(of double)replacing arraylist. The reason I am asking about collection is a different case, because Chart FX datasource allow either arraylist or collection. if you give me declaration (example) for "collection" object of generic type that would be very halp full.
Thanks
Abdul
|
|
|
|
|
You should use Option Strict On , then the compiler would tell you what the problem is. Actually, that should be part of the company standard, rather than restricting the classes to use.
Compiling the line
lst.add(arrlst(i)) with Option Strict On will give you the error message that implicit conversion from Object to Double is not allowed. With Option Strict Off , the compiler will turn the line into:
lst.add(Convert.ToDouble(arrlst(i))) which explains why it turns your null value (Nothing) into a zero. Calling Convert.ToDouble with a null reference does actually return zero.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for your timely explanation. In another case I am binding arraylist as chart fx datasource, As i have to remove all arraylist from my application(as per my company new standards). the only choice I have is binding a collection of generic type like double, string.
So please give a small example or declaration part for building a collection of generic type.
Thanks in advance.
Abdul
|
|
|
|
|
I'm trying to update a drop down list (DropDownList2) after selecting an item from another drop down list (DropDownList1). Both are set to autopostback. I've set the update panel to both conditional and always with the same result. Nothing happens. However, it works without the update panel. So I suppose that is the source of my problem..
Please help me.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection QADatabase = new SqlConnection();
QADatabase.ConnectionString = SqlDataSource1.ConnectionString;
QADatabase.Open();
SqlCommand command = new SqlCommand("SELECT Machines FROM Machines WHERE DeptID=" + DropDownList1.SelectedIndex ,QADatabase);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
DropDownList2.Items.Add((string)reader["Machines"]);
UpdatePanel1.Update();
}
QADatabase.Close();
}
|
|
|
|
|
Clearly there are a couple of things wrong with your code. First you don't clear out the dropdownlist2 before the while statement. If you don't do this you will continue to add new items to your dropdown everytime. Second are you sure you select command is returning any rows. I am guessing it is not since you are setting the deptID = to the selectedIndex. I think you would want to set it to the SelectedValue, assuming you set up this dropdown with the selected value containing the deptid.
Hope that helps.
Ben
|
|
|
|
|
The SQL statement returns all Machines in the database with deptID = to the selected index. This is what I want, and I've tested by just putting the data into a string while debugging and it returns the correct values. It returns the correct values when not using the UpdatePanel. It just reloads the entire page. I just haven't implemented the UpdatePanel right.. (P.s I added code to clear the list, thanks for noticing that.)
|
|
|
|
|
|
Thanks Ben. I wasn't adding all of my controls and my data source to the update panel. Just the output control. I added the rest of the related controls and my data source and it updated correctly.
|
|
|
|
|
Glad you figured it out.
Ben
|
|
|
|
|
can you plz help me I have an iframe that I want to access and refresh from another iframe how can I do that in aspx
BiG RaLpH
|
|
|
|
|
IFrame is a HTML componenet. I has nothing to do with ASP.NET. You can deal this with javascript. Get IFrame object using Javascript, then use src to set the IFrame URL.
Hope this helps
|
|
|
|
|
Hi everyone.
I've been handed a Web application that dynamically loads custom UserControls.
Upon a useraction, clicking a link to a given "page" (UserControl), I instanciate the
control using the Page.LoadControl method, store it to Session["Control"], and add it to PlaceHolder.Controls.
This seemed to work out perfectly as the control was maintained on the postback and the state was also maintained. But after I started implementing a button eventhandler I noticed that the event is never caught when the button is clicked and the control refreshes.
I'm not that familiar with Asp.Net as I usually work with windows applications and services.
Could anyone please point me in the right direction of how to avoid loosing the event in the postback?
Best regards!
-Larantz-
|
|
|
|
|
Hey
First things first - check that the event is wired up correctly - think off the top of my head this is done in oninit or some other initialisation function within the page:
http://msdn2.microsoft.com/en-us/library/ms743596.aspx
If this doesnt fix it then make sure that ISS is using the correct version of .NET. If this doesnt work then google asp.net event not firing as there is loads of help (I had this problem too) - i cant remember how i changed the version of .NET but it is in the properties.
Hope this helps
Dan
|
|
|
|
|
i have a date .can i convert the month into monthname
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
Call the ToString(String) method on your DateTime structure, passing in a format string of "MMMM".
Paul Marfleet
|
|
|
|
|
ThanQ
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
hi,
I have taken two file upload control (fileUpload1 and fileUpload2) and two required field validator(requiredFieldValidator1 and requiredFieldValidator2) for the two upload controls mentioned above.i.e requiredFieldValidator1 for fileUpload1 and requiredFieldValidator2 for fileUpload2.Now there are two button btnUpload1 and btnUpload2 for two controls.i.e btnUpload1 is for uploading file of name given to fileUpload1 control and btnUpload2 is for uploading file of the name given to fileUpload2.Now what is happening is that when i gave valid file name in fileUpload1 and clicked btnUpload1, it also checks for fileUpload2 and depending on its container, it is throwing exceptions.Like if fileUpload2 has file name given, no error but when there is no file name given in fileUpload2, it is giving error.However, the requiredFieldValidator1 shouldn't check for fileUpload2.The control to validate for requiredFieldValidator1 is fileUpload1 and for requiredFieldValidator2 is fileUpload2. And the same error comes when i try to upload the file of fileUpload2 and click btnUpload2.Well i am using ASP DOT NET 2005 using C# . But when i use only one Required Field Validator, it works fairly..Why this error is coming when using two Required Field Validator...How to solve this ...
suchitamanandhar@hotmail.com
|
|
|
|