Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > register start up script hell

Reply
Thread Tools

register start up script hell

 
 
AmitKu
Guest
Posts: n/a
 
      12-13-2006
I'm trying to use RegisterStartupScript.

I am making a call to it in Page_Load...and nothing shows up. Well
that not's entirely true. Half the pages I've put it on do work
properly, but the other half just don't work at all. Nothing shows up
at all.

How can I debug this? What are possible causes?

Thanks,
Amit

 
Reply With Quote
 
 
 
 
AmitKu
Guest
Posts: n/a
 
      12-13-2006
Just so you know...I deleted everything and tried this and it still
failed....

protected void Page_Load( object sender, EventArgs e )
{
string newscript = "<script>hello</script>";
Page.ClientScript.RegisterStartupScript( this.GetType(),
"randomScript", newscript );
bool fDidItWork = Page.ClientScript.IsStartupScriptRegistered(
"randomScript" );
}

and fDidItWork = false at the end of this.

Why??

--Amit

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWFuaXNoIEJhZm5h?=
Guest
Posts: n/a
 
      12-14-2006
Hi,
Just change following line of code:
Incorrect One :string newscript = "<script>hello</script>";
Correct One:string newscript = "<script>alert('Hello ASP.NET'); </script>";

if it is still not working then let me know

Thanks and regards,
manish bafna


"AmitKu" wrote:

> Just so you know...I deleted everything and tried this and it still
> failed....
>
> protected void Page_Load( object sender, EventArgs e )
> {
> string newscript = "<script>hello</script>";
> Page.ClientScript.RegisterStartupScript( this.GetType(),
> "randomScript", newscript );
> bool fDidItWork = Page.ClientScript.IsStartupScriptRegistered(
> "randomScript" );
> }
>
> and fDidItWork = false at the end of this.
>
> Why??
>
> --Amit
>
>

 
Reply With Quote
 
=?Utf-8?B?TWFuaXNoIEJhZm5h?=
Guest
Posts: n/a
 
      12-14-2006
Hi,
you can try following code also:

Page.ClientScript.RegisterStartupScript(this.GetTy pe(), "randomScript",
" alert('Hello ASP.NET'); ", true);

In the previous example, you are specifying a Boolean value setting of True
so that .NET places the script on the ASP.NET page with <script> tags
automatically.

Thanks and Regards,
manish bafna





"AmitKu" wrote:

> Just so you know...I deleted everything and tried this and it still
> failed....
>
> protected void Page_Load( object sender, EventArgs e )
> {
> string newscript = "<script>hello</script>";
> Page.ClientScript.RegisterStartupScript( this.GetType(),
> "randomScript", newscript );
> bool fDidItWork = Page.ClientScript.IsStartupScriptRegistered(
> "randomScript" );
> }
>
> and fDidItWork = false at the end of this.
>
> Why??
>
> --Amit
>
>

 
Reply With Quote
 
AmitKu
Guest
Posts: n/a
 
      12-14-2006
Nope doesn't work at all...same result.

I was originally using some real javascript, before even trying just
the "hello" to see if anything would work. So it's not a matter of
using real javascript.

--Amit


Manish Bafna wrote:
> Hi,
> Just change following line of code:
> Incorrect One :string newscript = "<script>hello</script>";
> Correct One:string newscript = "<script>alert('Hello ASP.NET'); </script>";
>
> if it is still not working then let me know
>
> Thanks and regards,
> manish bafna
>
>
> "AmitKu" wrote:
>
> > Just so you know...I deleted everything and tried this and it still
> > failed....
> >
> > protected void Page_Load( object sender, EventArgs e )
> > {
> > string newscript = "<script>hello</script>";
> > Page.ClientScript.RegisterStartupScript( this.GetType(),
> > "randomScript", newscript );
> > bool fDidItWork = Page.ClientScript.IsStartupScriptRegistered(
> > "randomScript" );
> > }
> >
> > and fDidItWork = false at the end of this.
> >
> > Why??
> >
> > --Amit
> >
> >


 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      12-14-2006

when you register the script, you use the type object to create a
namespace for register scripts. when you check if registered you do not
pass the type so you are checking in a different namespace, so it
responds no.

when you register a startup script it is rendered just before the
</form>. as long as there are no redirect, transfer, response.end or
clear content calls it should render.

-- bruce (sqlwork.com)



AmitKu wrote:
> Just so you know...I deleted everything and tried this and it still
> failed....
>
> protected void Page_Load( object sender, EventArgs e )
> {
> string newscript = "<script>hello</script>";
> Page.ClientScript.RegisterStartupScript( this.GetType(),
> "randomScript", newscript );
> bool fDidItWork = Page.ClientScript.IsStartupScriptRegistered(
> "randomScript" );
> }
>
> and fDidItWork = false at the end of this.
>
> Why??
>
> --Amit
>

 
Reply With Quote
 
AmitKu
Guest
Posts: n/a
 
      12-14-2006
Hi Bruce,

You were right about IsStartupScript....but the thing just doesn't show
up. I don't know what to tell you....no redirect, transfer,
response.end or clear content calls are made.

What could I be doing wrong?

Thanks,
Amit


bruce barker wrote:
> when you register the script, you use the type object to create a
> namespace for register scripts. when you check if registered you do not
> pass the type so you are checking in a different namespace, so it
> responds no.
>
> when you register a startup script it is rendered just before the
> </form>. as long as there are no redirect, transfer, response.end or
> clear content calls it should render.
>
> -- bruce (sqlwork.com)
>
>
>
> AmitKu wrote:
> > Just so you know...I deleted everything and tried this and it still
> > failed....
> >
> > protected void Page_Load( object sender, EventArgs e )
> > {
> > string newscript = "<script>hello</script>";
> > Page.ClientScript.RegisterStartupScript( this.GetType(),
> > "randomScript", newscript );
> > bool fDidItWork = Page.ClientScript.IsStartupScriptRegistered(
> > "randomScript" );
> > }
> >
> > and fDidItWork = false at the end of this.
> >
> > Why??
> >
> > --Amit
> >


 
Reply With Quote
 
AmitKu
Guest
Posts: n/a
 
      12-14-2006
Anybody else? It just doesn't show up....any ideas?

Thanks,
Amit

AmitKu wrote:
> Hi Bruce,
>
> You were right about IsStartupScript....but the thing just doesn't show
> up. I don't know what to tell you....no redirect, transfer,
> response.end or clear content calls are made.
>
> What could I be doing wrong?
>
> Thanks,
> Amit
>
>
> bruce barker wrote:
> > when you register the script, you use the type object to create a
> > namespace for register scripts. when you check if registered you do not
> > pass the type so you are checking in a different namespace, so it
> > responds no.
> >
> > when you register a startup script it is rendered just before the
> > </form>. as long as there are no redirect, transfer, response.end or
> > clear content calls it should render.
> >
> > -- bruce (sqlwork.com)
> >
> >
> >
> > AmitKu wrote:
> > > Just so you know...I deleted everything and tried this and it still
> > > failed....
> > >
> > > protected void Page_Load( object sender, EventArgs e )
> > > {
> > > string newscript = "<script>hello</script>";
> > > Page.ClientScript.RegisterStartupScript( this.GetType(),
> > > "randomScript", newscript );
> > > bool fDidItWork = Page.ClientScript.IsStartupScriptRegistered(
> > > "randomScript" );
> > > }
> > >
> > > and fDidItWork = false at the end of this.
> > >
> > > Why??
> > >
> > > --Amit
> > >


 
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
Java Web Start Icons, please register your preference. Roedy Green Java 18 03-26-2008 11:10 AM
How to programmatically register the __DOPOSTBACK script Henri ASP .Net 2 11-07-2004 11:40 PM
Register client script question Hardy Wang ASP .Net 3 10-26-2004 07:20 PM
Best way to Register Client Script objects? Darren Clark ASP .Net 1 08-02-2004 01:05 PM
Register client script at the end of the page. Arjen ASP .Net 2 08-13-2003 08:52 PM



Advertisments