在 C# Asp.Net 中,我需要将中继器出现索引传递到 Javascript 函数中OnClientClick
从 ASP 按钮按下。这是我的代码
<asp:Button ID="btnGetNewQuote"
Text="Get New Quote"
class="pcbutton"
runat="server"
OnCommand="GetNewQuote"
CommandArgument ='<%# Container.ItemIndex %>'
OnClientClick="return getNewQuote(<%# Container.ItemIndex %>) />
如果我硬编码 ....OnClientClick="return getNewQuote(0)"> 它可以工作并且 JS 会被调用,但是一旦我将 # Container.ItemIndex # 放入其中,JS 就会被忽略,它只会发回后面的代码...
通过Container.ItemIndex
into JS Functions 可以在页面上的其他任何地方工作,除了这个OnClientClick
?
有谁知道这是为什么以及我能做些什么来解决它?
Try this
OnClientClick='<%# "return getNewQuote(" + Container.ItemIndex + ")" %>'
代替
OnClientClick="return getNewQuote(<%# Container.ItemIndex %>)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)