Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am calling a javascript function in the aspx page i.e source code itself onload

My code sample is:
JavaScript
<asp:Content ID="head" ContentPlaceHolderID="headcontent" Runat="Server">
function func1()
{
alert('the code i want to bind to dropdownlist ');
}
window.onload=func1
function func2()
{
alert('hai');
}

but it was not working

Is there any way of using window.onload in content pages?
Posted
Updated 20-Nov-11 20:59pm
v2
Comments
JF2015 21-Nov-11 2:59am    
Edited to add code formatting.

1 solution

Hi,

Try the following

C#
function test() {
           alert('Page Loaded');
       }
       window.onload = function () { test() };

or
window.onload = function () {
C#
alert('Page Loaded');

};


Hope this helps.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900