I have this code in page_load method:
string orgId = Session["Lineage"].ToString().Split(';')[depth];
hidOrg.Value = orgId;
This in the aspx page:
<input type="hidden" id="hidOrg" runat="server" />
and
function doRetrieveData(objVal) {
var org = document.getElementById("hidOrg").value;
//do stuff
window.location.href = "summary.aspx?multiple=" + org
}
The problem is, I'm getting an object expected error when assigning var org the value of the hidden "hidOrg" field. Thanks for any help in advance.
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:
var org = document.getElementById('<%=hidOrg.ClientID%>').value;
Other approaches:
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.
onchange="doRetrieveData(this.value,this.nextSibling.value)
Set the Hidden-Field's ClientIdMode to Static
(if using .NET 4.0)