Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  24] [ 3]  / answers: 1 / hits: 65888  / 14 Years ago, tue, april 20, 2010, 12:00:00

How can I call a javascript function, that is in the aspx page, from the Page_Load method, in the code-behind?


More From » c#

 Answers
7

The easiest way is to use the page's ClientScript property. You can register some code to run when the page loads using something like



ClientScript.RegisterStartupScript(GetType(), hiya, alert('hi!'), true);


See http://msdn.microsoft.com/en-us/library/asz8zsxy.aspx for more info.



This should be available from a child control by tacking Page. onto the beginning of the code above.


[#97025] Friday, April 16, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dequant

Total Points: 88
Total Questions: 99
Total Answers: 95

Location: Ukraine
Member since Sun, Dec 13, 2020
4 Years ago
dequant questions
;