2
votes

I have 40 asp.net dropdownlists in my webpage. When i bind the controls in serverside using DataBind() it is taking 12 seconds, during which the page is blank. Without the databind, the page loads in 1 second.

So i decided to do the binding at client side. When i googled, i got this link. But the problem i am facing is, when i use PopulateControl() in javascript, i will get only the SelectedIndex during the postback.

The asp.net dropdown has the properties like SelectedIndex, SelectedValue, SelectedText. These properties are used a lot in the code-behind and changing the logic based on selected index would be very tough for me.

Is there a way where i can bind the control with javascript and get all those properties during postback.

Thanks in advance.

1

1 Answers

2
votes

As the items in the drop downs were not there on page load they will not be accessible in the normal ASP.net way. Use the request object to get the selected values:

string selVal = request.Form["dropDownName"]; //C# code

Be careful if you are using MasterPages or other naming containers as the name passed in the Request object may be mangled.

You could also use a plain HTML select control here.