N
nz mark in aus
Hi there
I am populating an empty <asp:dropdownlist on the client side using
Javascript using the following code
Heres my dropdown list
<asp:dropdownlist id="ddlDealers" Runat="server"></asp:dropdownlist>
heres the Java
var myDropDownList = frmMain.ddlDealers;
for (var cnt=0;cnt<=dealers.length-1;cnt = cnt + 2){
var opt = new Option(dealers[cnt],dealers[cnt],0,0);
myDropDownList.options[myDropDownList.options.length] = opt;
}
where dealers() is an array of values
the list is populated correctly and it all looks fine
my problem is that when I post the page using a <:asp Button the
selected value of the list is not being picked up on the server. Lets
say I selected 'Steve' in my drop down list, a simple test in my
Page_onload as follows returns NULL.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Write myDropDownList.SelectedValue
End Sub
The only time I can get the selected value from a dropdown is when I
have populated the drop down at the server in the normal .NET fashion,
but this requires an extra trip to the server which I am trying to
avoid.
Any ideas??
Mark
I am populating an empty <asp:dropdownlist on the client side using
Javascript using the following code
Heres my dropdown list
<asp:dropdownlist id="ddlDealers" Runat="server"></asp:dropdownlist>
heres the Java
var myDropDownList = frmMain.ddlDealers;
for (var cnt=0;cnt<=dealers.length-1;cnt = cnt + 2){
var opt = new Option(dealers[cnt],dealers[cnt],0,0);
myDropDownList.options[myDropDownList.options.length] = opt;
}
where dealers() is an array of values
the list is populated correctly and it all looks fine
my problem is that when I post the page using a <:asp Button the
selected value of the list is not being picked up on the server. Lets
say I selected 'Steve' in my drop down list, a simple test in my
Page_onload as follows returns NULL.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Write myDropDownList.SelectedValue
End Sub
The only time I can get the selected value from a dropdown is when I
have populated the drop down at the server in the normal .NET fashion,
but this requires an extra trip to the server which I am trying to
avoid.
Any ideas??
Mark