how to set the value of a dropdown to its default when page is refreshed with javascript or .net

Posted by Praveen7k under ASP.NET on 6/13/2011 | Points: 10 | Views : 2579 | Status : [Member] | Replies : 3
how can i set the value of dropdown to its default value ..i did like this

in page load event of page

dd.selectedvalue=""



and i have another question ...how to call onchange event of a dropdown on page load
< asp: dropdownlist id="" onchage="hidecontrol(this.value)" runat=""/> how to call this function of dropdown on pageload




Responses

Posted by: Sksingh on: 6/13/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Praveen,

First insert default value as below

dd.Items.Insert(0, "");
or
dd.Items.Insert(0,"Select")


and then set the index
dd.SelectedIndex = -1;


Regards,
Sunil

Praveen7k, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Praveen7k on: 6/13/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks..

This is working only for the first time...when i refresh it'snot working

Praveen7k, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 6/13/2011 [Member] Starter | Points: 25

Up
0
Down
Put above code outside of IsPostback method and then try it .

Regards,
Sunil

Praveen7k, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response