Facebook Twitter Gplus LinkedIn YouTube Google Maps RSS
Home Technical Javascript Onload event for Default pages with Master Pages
formats

Javascript Onload event for Default pages with Master Pages

Published on January 24, 2010 by in Technical

I have an asp.net website and I have created a default page (Default.aspx) with MasterPage. Like this i have created many pages (.aspx) with the same MasterPage.

Now i want to write a javascript body onload event only to Default.aspx. How can i do this? because body tag is in master page. but i want to use it only to Default.aspx.

in the cs file put following line
ClientScript.RegisterStartupScript(ClientScript.GetType(), “onLoad”, “fnTest()”, true);

In aspx file put following line

<script type=”text/javascript”>
        function fnTest()
        {
            alert(‘Hi’);
         }
</script>

 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
1 Comment  comments 

One Response

  1. Wow! This helped me soooo much!
    Thanks IR0N0RR, your the man and the legend!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

12,871 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© All rights reserved to Cyberbrutus. 2012
credit

Switch to our mobile site