Call javascript function from webpart

Ashutosh Pandey asked on December 18, 2019 16:27

May be duplicate but how can I do this in a webpart?

ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel();", true);

What should I import for this? Importing from Page is not working

Correct Answer

Brenden Kehren answered on December 18, 2019 16:48

This article is a great reference for this exact question.

Although I'm not sure what version you're on, it looks like your syntax is incorrect.

ScriptHelper.RegisterStartupScript(this, typeof(string), "alert", "HideLabel();", true);

0 votesVote for this answer Unmark Correct answer

Recent Answers


Ashutosh Pandey answered on December 18, 2019 16:51

Thanks a lot Brenden, works perfect.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.