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.
Asked
Active
Viewed 4,001 times
2
-
how will you be using ids on popup? put some value in those fields or read something from them? – TheVillageIdiot Nov 02 '10 at 06:28
-
Thanks for the reply. There will grid of items on my popup window of which a user may select one, it would then close the popup window and set the textbox field & hidden field value on parent page. – Zo Has Nov 02 '10 at 06:36
2 Answers
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]");

JumpingJezza
- 5,498
- 11
- 67
- 106
-
It might not be my requirement now but the explanation and approach is very informative. +1 – Zo Has Nov 02 '10 at 06:55
2
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);

TheVillageIdiot
- 40,053
- 20
- 133
- 188