Passing Parameters To Popup Window?
I am trying to pass parameters to a popup window via query string(a hidden field id & a textbox id). However, since I am using master pages the id's are very long (ct100_someid
Solution 1:
you can define function on parent page which can be accessed by popup window to set values of fiedls:
On parent page
function setHiddenValues(a,b,c){
document.getElementById("<%= hiddenField1.ClientID%>").value = a;
document.getElementById("<%= hiddenField2.ClientID%>").value = b;
document.getElementById("<%= hiddenField3.ClientID%>").value = c;
}
On popup page, after user selects row:
parent.setHiddenValues(val1, val2, val3);
Solution 2:
I like to encrypt the querystring so the curious user doesn't feel compelled to try replacing ?CustID=1&etc
with ?CustID=2&etc
for example. This is just for convenience as I also do a check in the code behind to make sure the customer looking at the page is authenticated, but IMHO looks more professional. See here for an example in vb.net.
To pass a shorter name you can also use jquery to select the hidden field using the id attribute rather than the whole client ID,
eg :
<asp:net HiddenField id="hdnName" runat="server" />
var hiddenfield = $("element[id$=_hdnName]");
Post a Comment for "Passing Parameters To Popup Window?"