0

I am having a problem with sending more than one control to a javascript function.

Here's My Code:

<telerik:GridTemplateColumn DataField="ExpirationPeriod" SortExpression="ExpirationPeriod"
                        GroupByExpression="ExpirationPeriod Group By ExpirationPeriod" AutoPostBackOnFilter="true"
                        FilterControlWidth="40px" HeaderText="Expiration Period" UniqueName="ExpirationPeriod">
                        <ItemTemplate>
                            <%# Eval("ExpirationPeriod")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <font color="red"><strong>*</strong></font>
                            <telerik:RadNumericTextBox ID="TxtExpirationPeriod" Width="40px" onblur="doSomeWork(this, document.getElementById("<%=RfvExpirationPeriod.ClientID %>"));"
                                runat="server" MinValue="1">
                                <NumberFormat DecimalDigits="0" GroupSeparator="" />
                            </telerik:RadNumericTextBox>
                            <asp:RequiredFieldValidator ID="RfvExpirationPeriod" runat="server" ValidationGroup="save"
                                ErrorMessage="Required" ForeColor="Red" ControlToValidate="TxtExpirationPeriod"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>

so as it Explained i want to fire a javascript function called doSomeWork at the TxtExpirationPeriod onblur event with two controls (TxtExpirationPeriod, RfvExpirationPeriod).

Actuall i received the TxtExpirationPeriod control successfully but i didn't receive the RfvExpirationPeriod control and i have its value to be null

Here is My javascript Function:

<telerik:RadScriptBlock ID="RSBlock" runat="server">
<script type="text/javascript" language="javascript">
    function doSomeWork(ctrl1, ctrl2) {
        //Do Some Work with the two controls
        //ctrl1 is fine, I can get it
        //ctrl2 comes with null
    }
</script>

Please be notified that i can't find those controls directly in doSomeWork Function because i am in the edit mode of radgrid view and these controls are not visible.

1 Answer 1

1
  check <%=RfvExpirationPeriod.ClientID %> this value whether you get this value not null
  if correct value then
   check document.getElementById("<%=RfvExpirationPeriod.ClientID %>") 
  one of the result may be null.
Sign up to request clarification or add additional context in comments.

4 Comments

It gives me the following error 'The name 'TxtExpirationPeriod' does not exist in the current context' and this is what i notified at the post end, Because these controls are not visible as the are in the grid view edit mode. So i thought to send these controls with onblur event, So what i am facing exactly is that one of the two controls which is the 'TxtExpirationPeriod' sent successfully but the other one 'RfvExpirationPeriod' can't be sent to the function and goes with null value. Hope you understand me now
Thanks For your reply. This is what you are doing 'onblur="doSomeWork(this,5)"' Sending the control that caused blur and a static value with it. Now could you replace the static value '5' with another control Client Id. I did that by using That 'onblur="doSomeWork(this, document.getElementById("<%=RfvExpirationPeriod.ClientID %>"));" ' But it didn't work. Any Ideas?
i think your second control becomes null because no element with that client id exist and you are trying to fetch element having that client id. or it may be happen that client id itself null then you can't get that element , i gave 2 controls and its work so error is in document.getElementById("<%=RfvExpirationPeriod.ClientID %>")
I am grateful to your answer. Could you provide me with example that fetch my scenario?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.