将变量传递给转发器中的javascript图像按钮onclientclick [英] Passing variables to javascript in repeater imagebutton onclientclick
本文介绍了将变量传递给转发器中的javascript图像按钮onclientclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过imagebutton onclientclick事件将我的动态值传递给javascript函数。如果我像这样传递静态值,它工作正常
< asp:ImageButton ImageUrl = 〜/ Images / control_play_blue.png ForeColor = 透明
BorderStyle = 无 工具提示 = 聊天 runat = 服务器 ID = btnChat
< span class =code-attribute> OnClientClick < span class =code-keyword> = javascript:return openWindow('1') / >
但是如果我尝试传递动态值,它不起作用。
< ; asp:ImageButton ImageUrl = 〜/ Images / control_play_blue.png ForeColor = 透明 BorderStyle = 无 工具提示 = 聊天 runat = server ID = btnChat
OnClientClick = javascript:return openWindow(' +<%#Eval(PujaType) % < span class =code-keyword>> +')/>
我尝试了所有可能的组合,但它说标签格式不正确。任何人都可以帮忙吗?
解决方案
我认为你不需要+符号。 <%=进入模板。
javascript:return openWindow('<%#Eval(PujaType)%>')
I want to pass my dynamic value to a javascript function from an imagebutton onclientclick event. It works fine if I pass the static value like this
<asp:ImageButton ImageUrl="~/Images/control_play_blue.png" ForeColor="Transparent"
BorderStyle="None" ToolTip="Chat" runat="server" ID="btnChat"
OnClientClick="javascript:return openWindow('1')" />
However it doesn't work if I try to pass dynamic values as below.
<asp:ImageButton ImageUrl="~/Images/control_play_blue.png" ForeColor="Transparent" BorderStyle="None" ToolTip="Chat" runat="server" ID="btnChat"
OnClientClick="javascript:return openWindow('"+<%#Eval("PujaType") %>+"')" />
I tried all possible combinations however it says tag is not well formatted. Can anyone help on this?
解决方案
I don't think you need the + signs. <%= goes into the template.
javascript:return openWindow('<%#Eval("PujaType") %>')
这篇关于将变量传递给转发器中的javascript图像按钮onclientclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文