|
#1
|
|||
|
|||
|
hi all, How can I call Javascript function from aspx.cs code behind file? Can I directly call Javascript function from my C# code behind. Thanks in advance |
|
#2
|
|||
|
|||
|
Hi 9PM,
Set the Body tag in your page/master page to runat="server" and an id="TheBody". Write the script tag in your page: <script src="MyFunction.js" type="text/javascript"></script> Then in the code behind attach the onload attribute to the body tag. protected void Page_Load(object sender, EventArgs e) { MasterPageBodyTag = (HtmlGenericControl)Page.Master.FindControl("TheBo dy"); MasterPageBodyTag.Attributes.Add("Onload", "MyFunction()"); } Best regards, Jane
__________________
"Everything should be as simple as it is, but not simpler." Albert Einstein Last edited by Jane; 06-11-2008 at 02:15 PM. |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to increase my Google page rank? | captain | Advertising | 2 | 09-07-2009 04:40 AM |
| How to make page redirection in ASP.NET? | June | ASP.NET Programming | 1 | 08-21-2008 03:46 PM |
| Different Start Page in ASP.NET | Sage | ASP.NET Web Hosting | 1 | 06-03-2008 11:24 AM |
| How to redirect a user to a certain web page? | Peer | ASP.NET Programming | 1 | 04-15-2008 02:33 PM |
| Refresh a web page? | Loopy | ASP.NET Programming | 1 | 03-11-2008 12:36 PM |