How to call javascript function in page_load event without any control attachment
-
How to call javascript function in page_load event without any control attachment
Dre@m is not th@t wh@t u see in sleep.Dre@m is the thing which does not allow u to sleep
Read about ClientScriptManager.RegisterStartupScript[^] method.
Best wishes, Navaneeth
-
How to call javascript function in page_load event without any control attachment
Dre@m is not th@t wh@t u see in sleep.Dre@m is the thing which does not allow u to sleep
Try This one, Use this code in your Code Behind
Page.ClientScript.RegisterStartupScriptthis.GetType(), "JSFunc", "MyFunc();", true);
This is your JavaScript Code :
function MyFunc()
{alert('JS Calling From Code Behind'); }
Hope this will help you :D
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Try This one, Use this code in your Code Behind
Page.ClientScript.RegisterStartupScriptthis.GetType(), "JSFunc", "MyFunc();", true);
This is your JavaScript Code :
function MyFunc()
{alert('JS Calling From Code Behind'); }
Hope this will help you :D
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
How to call javascript function in page_load event without any control attachment
Dre@m is not th@t wh@t u see in sleep.Dre@m is the thing which does not allow u to sleep
Page.ClientScript
wont work in case if you are using AJAX in your page.At that time use Scriptmanager to register the clientscrit as
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), this.ClientID, "MyFunc();", true);
Rest will same as Abhijit said.Cheers!! Brij
-
How to call javascript function in page_load event without any control attachment
Dre@m is not th@t wh@t u see in sleep.Dre@m is the thing which does not allow u to sleep
you can also achive same thing by using jquery. and for more detail check jquery documentation on jquery site <script type="text/javascript" src="JavaScript/jquery.js"> </script> <script type="text/javascript"> $(document).ready(function(){ alert('page loaded'); });
-
How to call javascript function in page_load event without any control attachment
Dre@m is not th@t wh@t u see in sleep.Dre@m is the thing which does not allow u to sleep