This is a migrated thread and some comments may be shown as answers.

Get Javascript Function Value

1 Answer 36 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Rich asked on 19 Nov 2012, 10:11 PM
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.


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 22 Nov 2012, 10:06 AM

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.

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.
General Discussions
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question