Hi,
I have a repeater and I want to use 2 radnumerictextboxes in the template. Then I need to call a javascript function on one of them that will copy its value to the other control onblur
<telerik:RadNumericTextBox runat="server" ID="txtRisk" NumberFormat-DecimalDigits="2" Type="Number" Width="65" CssClass="BetslipTextBox" ShowSpinButtons="true" ButtonsPosition="Right" IncrementSettings-InterceptArrowKeys="true" IncrementSettings-Step="1" MinValue="5" MaxValue="9999" ></telerik:RadNumericTextBox>
<telerik:RadNumericTextBox runat="server" ID="txtWin" NumberFormat-DecimalDigits="2" Type="Number" Width="65" CssClass="BetslipTextBox" ShowSpinButtons="true" ButtonsPosition="Right" IncrementSettings-InterceptArrowKeys="true" IncrementSettings-Step="1" MinValue="5" MaxValue="9999" ></telerik:RadNumericTextBox>
I did this in code-behind:
RadNumericTextBox w = (RadNumericTextBox)e.Item.FindControl("txtWin");
RadNumericTextBox r = (RadNumericTextBox)e.Item.FindControl("txtRisk");
w.Attributes.Add("onblur", "return CalculateRisk(" + w.ClientID + "," + r.ClientID + ");");
in the javascript:
This shows me the value correctly:
alert(document.getElementById(win.id).value);
which is:
ctl00_ContentPlaceHolder1_rptName_ctl01_txtWin
but I can't set it
when I view source it shows that it added a "_text" to the end of the id so it really is:
ctl00_ContentPlaceHolder1_rptName_ctl01_txtWin_text
This does set it (when I hard code it):
document.getElementById('ctl00_ContentPlaceHolder1_rptStraight_ctl01_txtWin_text').value = "50";
What is the right way to do this? The above code does work for a regular asp:textBox but I want to use yours!
I also tried <ClientEvents OnBlur="TestOnBlur /> and was able to get the sender but how do I access the other controls if I cant pass them?
Thanks
I have a repeater and I want to use 2 radnumerictextboxes in the template. Then I need to call a javascript function on one of them that will copy its value to the other control onblur
<telerik:RadNumericTextBox runat="server" ID="txtRisk" NumberFormat-DecimalDigits="2" Type="Number" Width="65" CssClass="BetslipTextBox" ShowSpinButtons="true" ButtonsPosition="Right" IncrementSettings-InterceptArrowKeys="true" IncrementSettings-Step="1" MinValue="5" MaxValue="9999" ></telerik:RadNumericTextBox>
<telerik:RadNumericTextBox runat="server" ID="txtWin" NumberFormat-DecimalDigits="2" Type="Number" Width="65" CssClass="BetslipTextBox" ShowSpinButtons="true" ButtonsPosition="Right" IncrementSettings-InterceptArrowKeys="true" IncrementSettings-Step="1" MinValue="5" MaxValue="9999" ></telerik:RadNumericTextBox>
I did this in code-behind:
RadNumericTextBox w = (RadNumericTextBox)e.Item.FindControl("txtWin");
RadNumericTextBox r = (RadNumericTextBox)e.Item.FindControl("txtRisk");
w.Attributes.Add("onblur", "return CalculateRisk(" + w.ClientID + "," + r.ClientID + ");");
in the javascript:
This shows me the value correctly:
alert(document.getElementById(win.id).value);
which is:
ctl00_ContentPlaceHolder1_rptName_ctl01_txtWin
but I can't set it
when I view source it shows that it added a "_text" to the end of the id so it really is:
ctl00_ContentPlaceHolder1_rptName_ctl01_txtWin_text
This does set it (when I hard code it):
document.getElementById('ctl00_ContentPlaceHolder1_rptStraight_ctl01_txtWin_text').value = "50";
What is the right way to do this? The above code does work for a regular asp:textBox but I want to use yours!
I also tried <ClientEvents OnBlur="TestOnBlur /> and was able to get the sender but how do I access the other controls if I cant pass them?
Thanks