Rectangle 27 0

asp.net populating hidden field from codebehind, then, passing it back to codebehind as QueryString ASPjavascript?


BtnRetrieveData.Attributes.Add("onclick,"doRetrieveData("+ hidOrg.ClientID +")");
doRetrieveData
onchange="doRetrieveData(this.value,this.nextSibling.value)
var org = document.getElementById('<%=hidOrg.ClientID%>').value;

<select id="selDmaHierarchySelect" onchange="doRetrieveData(this.value)"> <option></option> <option value="1">Hierarchy</option> <option value="2">DMA</option> <option value="3">State</option>It is called from a dropdown list. like this:

ASP.NET generates server-control's ClientIDs according to the control's NamingContainer. So you need to pass the ClientID to your javascript function. Try this:

Pass the hiddenfield's value to the javascript function as well. You need to put the hiddenfield directly behind the DropDownList/Select and use nextSibling to get a reference to it.

Set the Hidden-Field's ClientIdMode to Static (if using .NET 4.0)

Then try my codebehind approach. Or put your hiddenfield next to the DropDownList and call doRetrieveData(this.nextSibling.value) to pass the hiddenfield-value directly from the DropDownList's clientside onchange event. w3schools.com/dom/prop_node_nextsibling.asp

Note