Reputation: 13038
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). Is there a way to elegantly pass my ids ?Can I shorten my id's or not show them to the user at all ? Please tell me any alternates.
Upvotes: 2
Views: 4201
Reputation: 40512
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);
Upvotes: 2
Reputation: 5675
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]");
Upvotes: 2