简体   繁体   中英

Please tell me what is error in this javascript code

i have written following code to access public variable of asp.net onclick event on button but its not giving me desired output.. please check it:

<asp:Button runat="server" CssClass="txtdisplay" ID="Button1"
 Text="Browse all jobs in area" 
OnClientClick="return navigateURL('index.aspx?c=<%=cityid %>')" />

You cannot inline anything for server controls. You have to do it in the code behind.

This:

"return navigateURL('index.aspx?c=<%=cityid %>')"

Should Be This:

Button1.OnClientClick = "return navigateURL('index.aspx?c=" + city + ")"; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM