传递直放站Container.ItemIndex JavaScript函数 [英] Passing Repeater Container.ItemIndex to a Javascript function

查看:117
本文介绍了传递直放站Container.ItemIndex JavaScript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#Asp.Net我需要我的中继器发生指数传递到一个Javascript功能时的OnClientClick 是从ASP按钮pssed德$ P $。这里是我的code

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 %>) />

如果我硬code ....的OnClientClick =返回getNewQuote(0)>它的工作原理和JS被调用,但只要我把#Container.ItemIndex#在那里JS被忽视它只是回发到code背后...

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...

薪火 Container.ItemIndex 成JS功能每天都要工作还有什么地方,除了此页面上的的OnClientClick

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?

推荐答案

试试这个

OnClientClick='<%# "return getNewQuote(" + Container.ItemIndex + ")" %>' 

而不是

OnClientClick="return getNewQuote(<%# Container.ItemIndex %>)

这篇关于传递直放站Container.ItemIndex JavaScript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆