Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > onLoad Javascript

Reply
Thread Tools

onLoad Javascript

 
 
chrispragash@hotmail.com
Guest
Posts: n/a
 
      08-29-2005
Hello all,

I am trying to hide a panel when my asp.net page first renders - the
objective is to toggle the visibility at the click of a button. I wrote
a javascript (with script like ClientID.style.visibility = "hidden"),
registered this script using Page.RegisterClientScriptBlock, and added
an Attribute to the control (Control.Attributes.Add("onLoad", "Id of
script")). The javascript is not being called at all!. Any ideas would
be of great help.

Regards,
Chris

 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      08-29-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hello all,
>
> I am trying to hide a panel when my asp.net page first renders - the
> objective is to toggle the visibility at the click of a button. I
> wrote a javascript (with script like ClientID.style.visibility =
> "hidden"), registered this script using
> Page.RegisterClientScriptBlock, and added an Attribute to the control
> (Control.Attributes.Add("onLoad", "Id of script")). The javascript is
> not being called at all!. Any ideas would be of great help.
>
> Regards,
> Chris


When you say "id of script", do you mean just the name of the function,
or even the code that you used registering the script block?
You should use the name of the function, followed by ( ) (that is, a plain function call).
The registration name has no meaning at all, client-side.

You could also use Page.RegisterStartupScript. This code will execute when most of
the page has already been loaded.

What does the generated code look like in the browser (do a "view source"
and search for your code)? You need to include the <script> tags
in the code-block.

Hans Kesting


 
Reply With Quote
 
 
 
 
chrispragash@hotmail.com
Guest
Posts: n/a
 
      08-29-2005
Hans,

Thanks for responding. In the attributes, I am actually specifying the
name of the javascript function, I verfied this by executing the
function in onClick and everything works fine. The problem is I want to
execute this when the page loads. And all this code is in a Server
control. Any ideas or suggestions?

Thanks,
Chris

 
Reply With Quote
 
Hans Kesting
Guest
Posts: n/a
 
      08-29-2005
(E-Mail Removed) wrote:
> Hans,
>
> Thanks for responding. In the attributes, I am actually specifying the
> name of the javascript function, I verfied this by executing the
> function in onClick and everything works fine. The problem is I want
> to execute this when the page loads. And all this code is in a Server
> control. Any ideas or suggestions?
>
> Thanks,
> Chris


Executing code in the onLoad of a *page* will work. Be sure to add a ";" after
your call, .Net may append code of it's own.
A *control* is not something that is recognised as a separate entity at the client,
so I don't think it's possible to add an onLoad handler to a *control*.

Hans Kesting



 
Reply With Quote
 
Bruce Barker
Guest
Posts: n/a
 
      08-29-2005
only the <body> tag has an onload event in the browser.

<body onload="myclientscript()">

you could put a runat server and id tag and do the add attribute. as you
just want to change the style, use the RegisterStartupScript (which renders
just before the </form> tag).

-- bruce (sqlwork.com)


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello all,
>
> I am trying to hide a panel when my asp.net page first renders - the
> objective is to toggle the visibility at the click of a button. I wrote
> a javascript (with script like ClientID.style.visibility = "hidden"),
> registered this script using Page.RegisterClientScriptBlock, and added
> an Attribute to the control (Control.Attributes.Add("onLoad", "Id of
> script")). The javascript is not being called at all!. Any ideas would
> be of great help.
>
> Regards,
> Chris
>



 
Reply With Quote
 
babie984 babie984 is offline
Junior Member
Join Date: Aug 2009
Posts: 1
 
      08-02-2009
hi.... am having a problem with javascripting. have this datepicker, want to show in the page that when the date picked is changed, the date in the textbox and the date picked in the end date will automatically changed into the selected start date. already can do this but the thing is still have to press enter. want it in a way that it will just automatically change. how can i do this? is there any chance that i can do this?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
onload -->* no onload marco Javascript 7 06-24-2006 08:39 PM
Why doesn't frameset onload event get called when each of the frames has an onload? adnanx82@gmail.com Javascript 5 05-15-2005 01:58 PM
base.OnLoad called, OnLoad not executed Fabio R. ASP .Net 0 03-25-2005 01:21 PM
window.onload and body.onload differences David Otton Javascript 2 11-04-2004 04:34 PM
ASP.NET /JavaScript Problem - Image onload John E ASP .Net 0 07-31-2003 03:11 PM



Advertisments