0

I have a unique situation and I can't find any help on it. I have a RadGrid that uses a User Web Control(.ascx) to insert and edit the grid items. I need to used javascript to get the value of two RadTextBox on the User Web Control and sum them together and then update a third RadTextBox with the result value.

Here is my problem: 1) I have to create the javascript on the parent aspx page in order for the User Web Control to see it. If I create it on the .ascx page, it doesn't see it. 2) Since I have to create it on the parent aspx page where the grid reside, I can't figure a way to access the RadTextBox value on the User Web Control.

Any help would be greatly appreciated. Is there a way to run the javascript within the User Web Control?

Anthony

zXSwordXz
  • 176
  • 4
  • 15

1 Answers1

0

I figure out the answer. The trick is to add my javascript in a RadScriptBlock in the .ascx page. Example of what I was trying to do:

       <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
       <script type="text/javascript">
         function getTotal() {
         var jan = $find("<%= txtJan.ClientID %>");
         var feb = $find("<%= txtFeb.ClientID %>");
         var mar = $find("<%= txtMar.ClientID %>");
         var apr = $find("<%= txtApr.ClientID %>");
         var may = $find("<%= txtMay.ClientID %>");
         var jun = $find("<%= txtJun.ClientID %>");
         var jul = $find("<%= txtJul.ClientID %>");
         var aug = $find("<%= txtAug.ClientID %>");
         var sep = $find("<%= txtSep.ClientID %>");
         var oct = $find("<%= txtOct.ClientID %>");
         var nov = $find("<%= txtNov.ClientID %>");
         var dec = $find("<%= txtDec.ClientID %>");
         var total = $find("<%= txtTotal.ClientID %>");
         total.set_value(jan.get_value() + feb.get_value() + mar.get_value() + apr.get_value() +         may.get_value() + jun.get_value() + jul.get_value() + aug.get_value() + sep.get_value() + oct.get_value() + nov.get_value() + dec.get_value());

     }
    </script>

This will sum the total of all the months into the txtTotal textbox.

zXSwordXz
  • 176
  • 4
  • 15