0

I need to call a javascript script before the page_load method in the MasterPage.cs.

I need to do this because I want to recover a javascript variable that will be used in the page_Load method.

Someone know how to do?

Thank you,

Quentin

1 Answer 1

1

In start of Page_Load or in Page_Init method you can call javascript like:

ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(this.Page.GetType(), "TestKey", "YourJavascriptMethod();", true);
Sign up to request clarification or add additional context in comments.

1 Comment

put an alert in your javascript method and see if it gets called.

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.