CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 2/4/2008 9:49:07 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 5 Views: 225 Favorited: 0 Favorite
6 Items, 1 Pages 1 |< << Go >> >|
Kiboumz
Asp.Net User
Javascript Body-OnLoad2/4/2008 9:49:07 PM

0

Hi,

I have a masterpage and subpages and I want to manage the body onload in my subpages (I want to call a javascript parameted function). How can I do that ?

like that : <body onload="MyFonction(myparam)"> or is there a way to call a javascript from the code-behind ?

thx
 

roni_schuetz
Asp.Net User
Re: Javascript Body-OnLoad2/4/2008 11:29:41 PM

0

you can use the following:

 

<script language='javascript' type='text/javascript'>
/*in case anything else is available*/

var yourVar = window.onload;

window.onload = function()

{

 if(yourVar)

{ yourVar(); }

//// here you add what you need ....

}

</script>


regards, roni
---
speed up your applications with distributed caching or replicated caching: http://www.sharedcache.com - its free!
RJA
Asp.Net User
Re: Javascript Body-OnLoad2/5/2008 2:01:50 AM

0

The Page.RegisterStartupScript will allow you to set the JS function to run on load from the code behind.  Here are details http://msdn2.microsoft.com/en-us/library/system.web.ui.page.registerstartupscript(vs.71).aspx 

You can then build the JavaScript by concatenating strings in the code behind, to build your paramaters. 

saifsaif
Asp.Net User
Re: Javascript Body-OnLoad2/5/2008 11:50:40 AM

0

Do the following in Page Load event

protected void Page_Load(object sender, EventArgs e)

{

  

Page.RegisterStartupScript("onload", "<script language='JavaScript'>MyFonction(myparam);</script>");

}

Thanks

Kiboumz
Asp.Net User
Re: Javascript Body-OnLoad2/5/2008 2:24:21 PM

0

Hi!

Page.RegisterStartupScript work great!

The only problem is that Page.RegisterStartupScript is an obsolete method. VS suggest to use ClientScript.RegisterStartupScript, but when I'm in a MasterPage, ClientScript is not accessible, anyone have an idea of what I can use ?

thx!
 

RJA
Asp.Net User
Re: Javascript Body-OnLoad2/5/2008 4:05:38 PM

0

 I meant to use the newer ClientScriptManager, but am stuck in old ways sometimes. :)

Anyway, here's the ClientScriptManger which can be used in a MasterPage (or regular page)

  String csname1 = "PopupScript";
String csname2 = "ButtonClickScript";
Type cstype = this.GetType();

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;

// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
String cstext1 = "alert('Hello World');";
cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}
}

 

6 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional JavaScript for Web developers Authors: Nicholas C. Zakas, Pages: 646, Published: 2005
Essential Java script for Web professionals Authors: Daniel J. Barrett, Dan Livingston, Micah Brown, Pages: 198, Published: 1999
Learning JavaScript: Add Sparkle and Life to Your Web Pages Authors: Shelley Powers, Pages: 396, Published: 2008
JavaScript: the definitive guide Authors: David Flanagan, Pages: 994, Published: 2006
JavaScript: A Beginner's Guide Authors: John Pollock, Pages: 550, Published: 2004

Web:
Using window.onload How to attach onload processing to a page without adding it to the body tag. ... the body tag, if you add the script into an existing external Javascript ...
HTML onLoad - HTML Code Tutorial The browser triggers onLoad when the document is finished loading. The contents of onLoad is one or more JavaScript commands. So, for example, this DevGuru JavaScript EVENT HANDLER: onload < input type="text" name="myText" > . ...
Background Image not showing up - macromedia.dreamweaver The Tag was in the code. Yes, but the definition of P7_ExpMenu() was not. It was that missing javascript that ...

Videos:
double slit experiment snow boarding kite surf surfing skate snowboarding snow quantum field effects super posistion the edge boarding industries bitchwax the board ...
Home Based Business Go To: www.EliteTeamWebinar.com Rigo ... Home Based Business Go To: www.EliteTeamWebinar.com Call 1(800) 262-3312 ID: RD133 Learn To Earn Thousands of Dollars Per Week Even For Your ...
Home Based Business Go To: www.EliteTeamWebinar.com Rigo ... Home Based Business Go To: www.EliteTeamWebinar.com Call 1(800) 262-3312 ID: RD133 Learn To Earn Thousands of Dollars Per Week Even For Your ...
OpenSocial Tutorial - Part 4: Listing Gifts You've Sent Part 4 of 5 videos describing how to build your first OpenSocial application. Dan Holevoet goes over sample code that shows you how to display ...
Line Rider (-) Jimmy Carr - Awards






removing escape charcaters from a string

using a session variable in connectionstring

regular expression validator

handling a file upload system with many users

read function from global.asax

another inheritance question

mail sending error

button in side a datalist

asp pages don't open

"cavalcading turnstile sheep" question

url mappings from database

getting the sum() in sqldatareader

activex vs. user control

runtime error but customerrors is off

auto increment a number in a sql database

writing to html file(caching??)

how can i use session with system.componentmodel.icomponent interface ?

adding <br> to datatable

first time user

picture dont change till i clear browser history

what is mean by cronjob?

weird asp.net 2.0 bug! viewstate showing briefly in the browser on post back!

typed dataset

pages and postback

change style in user control

how do you create a new web reference on particular server?

error connecting to sql 2005 box (beta 2)

byval with reference types

can not go live

online payment website

   
  Privacy | Contact Us
All Times Are GMT