Quentin91360
Quentin91360

Reputation: 122

Call Javascript script before page_load method in Master page

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

Upvotes: 0

Views: 1853

Answers (1)

Imran Balouch
Imran Balouch

Reputation: 2170

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);

Upvotes: 1

Related Questions