admin管理员组文章数量:1403468
In C# Asp.Net I need to pass my repeater occurrence index into a Javascript function when OnClientClick
is depressed from an ASP button. Here is my code
<asp:Button ID="btnGetNewQuote"
Text="Get New Quote"
class="pcbutton"
runat="server"
OnCommand="GetNewQuote"
CommandArgument ='<%# Container.ItemIndex %>'
OnClientClick="return getNewQuote(<%# Container.ItemIndex %>) />
If I hard code ....OnClientClick="return getNewQuote(0)"> it works and the JS gets invoked, but as soon as I put the # Container.ItemIndex # in there the JS gets overlooked and it just posts back to the code behind...
Passing the Container.ItemIndex
into JS Functions works every where else on the page except this OnClientClick
?
does anyone know why this is and what I can do to get around it?
In C# Asp.Net I need to pass my repeater occurrence index into a Javascript function when OnClientClick
is depressed from an ASP button. Here is my code
<asp:Button ID="btnGetNewQuote"
Text="Get New Quote"
class="pcbutton"
runat="server"
OnCommand="GetNewQuote"
CommandArgument ='<%# Container.ItemIndex %>'
OnClientClick="return getNewQuote(<%# Container.ItemIndex %>) />
If I hard code ....OnClientClick="return getNewQuote(0)"> it works and the JS gets invoked, but as soon as I put the # Container.ItemIndex # in there the JS gets overlooked and it just posts back to the code behind...
Passing the Container.ItemIndex
into JS Functions works every where else on the page except this OnClientClick
?
does anyone know why this is and what I can do to get around it?
Share Improve this question edited Jan 10, 2013 at 10:49 yogi 19.6k13 gold badges64 silver badges93 bronze badges asked Jan 10, 2013 at 10:47 AdamAdam 1112 silver badges14 bronze badges2 Answers
Reset to default 6Try this
OnClientClick='<%# "return getNewQuote(" + Container.ItemIndex + ")" %>'
Instead of
OnClientClick="return getNewQuote(<%# Container.ItemIndex %>)
If we want to use in vb
OnClientClick='<%# "return getNewQuote(" & Container.ItemIndex & ")" %>'
otherwise it will give exception string is not in correct format
本文标签: aspnetPassing Repeater ContainerItemIndex to a Javascript functionStack Overflow
版权声明:本文标题:asp.net - Passing Repeater Container.ItemIndex to a Javascript function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744386376a2603758.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论