Get Javascript Function Value

2 posts, 0 answers
  1. Rich
    Rich avatar
    31 posts
    Member since:
    May 2011

    Posted 19 Nov 2012 Link to this post

    Not sure where this one goes...

    I have a grid of companies that allows updates to the address of the company.  At the end of that update, I need to ask the user if they want to update the contacts associated with that company to the same address.

    Here the code that calls the javascript function:
            ClientScript.RegisterStartupScript(Me.GetType(), "ConfirmMessageBox", "confirmAddressChange(); ", True)

            If hfAddressChange.Value <> String.Empty Then
                Dim x As String = "Do Something here"

            End If

    And here is the javascipt it is calling:
            function confirmAddressChange()
            {
                 var res = (confirm('"Update Contact Addresses to Match?"')==true);
                 document.forms[0].hfAddressChange.valueOf = res;    
                 
            }

    Basically all I'm doing is getting the response from the user and putting it into a HiddenField on the form.

    Everything SEEMS to be working fine, except that the IF statement that checks the HiddenField runs before the confirmation box is run.

    How do I call the function and make sure it is run BEFORE I check for the value returned in the HiddenField?

    Any suggestions would be GREATLY appreciated.

    Thanks.
  2. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 22 Nov 2012 Link to this post

    Hello,

    I am not sure that I understand correctly what you mean. The code with if statement is executed on the server, the one with the JavaScript is executed from the client's browser, it is normal for the server code to be executed before the JavaScript.

    Could you elaborate what is the use case and how the user will submit the update process. Thus all the people who want to help you will have better understanding of your case and will be able to give you more specific directions.

    Greetings,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top