Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/404.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单值绑定_Javascript_Asp.net_Asp.net Controls_Onclientclick - Fatal编程技术网

Javascript 单值绑定

Javascript 单值绑定,javascript,asp.net,asp.net-controls,onclientclick,Javascript,Asp.net,Asp.net Controls,Onclientclick,其目的是在OnClientClick事件中附加javascript代码,以作为ID参数传入SearchIDTextbox的值。如果我硬编码“22”为????这个 函数运行正常。我想我需要做点什么????单值绑定表达式 但是我在设置代码时遇到了麻烦 <asp:ImageButton ID="PremiumUserImageButton" Width="40px" OnClientClick="return clientClickEvent('AdvancedSearch.aspx?ID= ?

其目的是在OnClientClick事件中附加javascript代码,以作为ID参数传入SearchIDTextbox的值。如果我硬编码“22”为????这个 函数运行正常。我想我需要做点什么????单值绑定表达式 但是我在设置代码时遇到了麻烦

<asp:ImageButton ID="PremiumUserImageButton" Width="40px" OnClientClick="return clientClickEvent('AdvancedSearch.aspx?ID= ???? )" CausesValidation="False" ImageUrl="~/Images/Premium.gif" runat="server" />


试过了,运气不好

<asp:ImageButton ID="PremiumUserImageButton"  Width="40px" OnClientClick="return clientClickEvent('AdvancedSearch.aspx?ID='<%# GetID() %>'" CausesValidation="False" ImageUrl="~/Images/Premium.gif" runat="server" />

在代码中添加了额外的撇号。此外,javascript函数没有任何括号

请用下面的代码替换您的代码

<asp:ImageButton ID="PremiumUserImageButton"  Width="40px" OnClientClick="return clientClickEvent('AdvancedSearch.aspx?ID=<%# GetID() %>');" CausesValidation="False" ImageUrl="~/Images/Premium.gif" runat="server" />

你也可以在firebug中检查这个标签,firebug是firefox最好的插件


希望这对您有所帮助。

需要首先通过javascript中的
document.getelementbyid
方法获取
searchTextbox
的值,并将其作为参数分配给函数。