Reputation: 171
I have a Button and I am trying to include query string from the URL, but I couldn't get it to work.
Please help.
<asp:Button ID="myBtn" runat="server" Text="Upload Company/Contact" CssClass="button3"
OnClientClick="window.parent.location.href='/Apps/ERP/ASPX/UploadContact/UploadContact.aspx?RefNum=" + <%# Request.QueryString["RefNum"]%>'; return false;" />
Upvotes: 0
Views: 508
Reputation: 1295
Just Check it out following url, Very well explain server tag. http://weblogs.asp.net/ahmedmoosa/archive/2010/10/06/embedded-code-and-inline-server-tags.aspx
In your case ps2goat is right, you are trying to set Server Side code in Client Side, You need to use '<%= %>'
syntax.
Let me know if u need any further help.
Upvotes: 0
Reputation: 8475
%#
is for binding, %=
is for setting. In this case, you need to set the value.
I'd also change the calculation to do a string concatenation:
<asp:Button ID="myBtn" runat="server"
Text="Upload Company/Contact" CssClass="button3"
OnClientClick='<%= "window.parent.location.href='/Apps/ERP/ASPX/UploadContact/UploadContact.aspx?RefNum=" + Request.QueryString["RefNum"] + "';return false;" %>' />
And like @MikeSmithDev said, you can set this in the code behind, such as Page_Load:
myBtn.OnClientClick = "window.parent.location.href='/Apps/ERP/ASPX/UploadContact/UploadContact.aspx?RefNum=" +
Request.QueryString["RefNum"] + "';return false;";
Upvotes: 1