单值绑定

时间:2013-05-20 04:05:05

标签: javascript asp.net asp.net-controls onclientclick

目的是在OnClientClick事件中附加javascript代码,以传递SearchIDTextbox的值作为ID参数。如果我硬编码“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" />

1 个答案:

答案 0 :(得分:0)

在你的代码中你放了额外的撇号。除了javascript函数没有任何支架关闭。

请使用以下代码替换您的代码。

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

你也可以在firebug中检查这个标签,这是firefox最好的添加。

希望这会对你有所帮助。