2012-11-09 52 views
0

你好,我有一个Repeater控件更新中继文本框与另一个文本框的keyup事件

<asp:Repeater ID="rptCashCome" runat="server"> 
    <ItemTemplate> 
      <asp:TextBox ID="txtCurrencyNo" onkeyup="javascript:CallFunction()" CssClass="mws-textinput" runat="server"></asp:TextBox> 
      <asp:TextBox ReadOnly="True" ID="txtTotal" CssClass="mws-textinput" runat="server"></asp:TextBox> 

    </ItemTemplate> 
    </asp:Repeater> 

我有一个jQuery函数

function CallFunction() { 

//code here i want something like. txtCurrencyNo* 500 = txtTotal 
// something like calculative here. but how will i find the Control ID of repeater ? 



} 

这个函数被调用。但我如何做基于文本框KeyUp的计算?我如何在这里找到控制ID?

回答

0

你可以为此用户jQuery。
使用

$(this).val() 

它会给你当前文本框的值。
如果其他文本框是相同的模板,那么你可以使用这样的(未测试)

function CallFunction() { 
    var firstTextBoxVal= $(this).val(); 
    $(this).next().val(firstTextBoxVal* 500) 
} 

改变你的中继如下

<asp:Repeater ID="rptCashCome" runat="server"> 
<ItemTemplate> 
     <asp:TextBox ID="txtCurrencyNo" onkeyup="javascript:CallFunction(this)" CssClass="mws-textinput" runat="server"></asp:TextBox> 
     <asp:TextBox ReadOnly="True" ID="txtTotal" CssClass="mws-textinput" runat="server"></asp:TextBox> 

</ItemTemplate> 
</asp:Repeater> 
+0

以及如何将它设置为另一个文本框? – Moiz

+0

,我没有得到这个价值。 – Moiz

+0

它不工作。它在相同的模板中,甚至没有发生。 – Moiz

相关问题