RegisterClientScriptBlock & RegisterStartupScript revisited

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: RegisterClientScriptBlock & RegisterStartupScript revisited

    Duh! As is often the case, I found the answer about the comment tags after I
    hit send.

    I would sill like to know about the difference in the 2 methods.


    Thanks
    Brian W

    "Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
    news:eDEGn2OQDHA.1024@TK2MSFTNGP12.phx.gbl...
    > Sorry to bring these methods up again, but I'm confused...
    >
    > I know that one writes the code block just after the <form> and the other
    > just before the </form>.
    >
    > So my question is, what difference does it make? When should one be used
    as
    > apposed to the other?
    >
    > And, while I'm on the subject of these 2 methods. The documentation for
    both
    > says:
    > "Note Remember to include HTML comment tags around your script so
    that
    > it will not be rendered if a requesting browser does not support scripts"
    >
    > First of all the example code does not use the HTML comment tags.
    >
    > Secondly, when I use the comment tags I get the error "Object expected"
    from
    > the java runtime.
    >
    > the script when I view source looks like this:
    >
    > <!--
    > <SCRIPT language='javascript'>
    > function WNS_OpenWindow(url, parms)
    > {
    > if (parms=='') parms =
    >
    'width=500,height=500,resizable=1,left=10,top=10,t oolbar=0,status=0,scrollba
    > rs=0,menubar=0,location';
    > newWin = window.open ( url, 'wndNew', parms);
    > }
    > </SCRIPT>
    > -->
    >
    > and I use it like this:
    >
    > <a id="PageHeaderControl__emailPage"
    >
    onclick="WNS_OpenWindow('/project/Tools/Email.aspx?popup=yes&amp;send=http%3
    > a%2f%2flocalhost%2fproject%2fDefault.aspx',
    > 'height=300,width=475,resizable=yes'); return false; "
    >
    href="/project/tools/email.aspx?send=http%3a%2f%2flocalhost%2fproject%2 fDefa
    > ult.aspx">Email this page to a friend</a>
    >
    > If I remove the comment tags everything works fine.
    >
    >
    > Thanks for any insight you can offer
    >
    > Brian W
    >
    >
    >

    Brian W Guest

  2. Similar Questions and Discussions

    1. referenceing ClientScript.RegisterStartupScript in control
      I think you want me.Page.ClientScript.RegisterStartupScript() +++ Rick --- "WebBuilder451" <WebBuilder451@discussions.microsoft.com> wrote in...
    2. DHTML and RegisterStartupScript
      I have some DHTML actions which work very well at a page level. However when I take everything and make a control it just falls apart. Everything...
    3. RegisterStartupScript firing at the wrong time
      I have a weird thing going on. I think I've figured out what's causing my problem, but I can't find any way to fix it. I have a custom server...
    4. RegisterStartupScript and IsStartupScriptRegistered not shown in listed methods of Page
      Hi All, I'm building an Webcontrol and overriding OnPreRender i want inject client javascript, but RegisterStartupScript and...
    5. client side script with RegisterStartupScript issue
      no, you can not control the order the blocks are rendered. you can concat the scripts and register them once. also if you are doing code like: ...
  3. #2

    Default Re: RegisterClientScriptBlock & RegisterStartupScript revisited

    Hello Brian,

    A control can place a startup script on a page via the
    Page.RegisterStartupScript method. This script will be automatically
    executed when the page is shown in the user's browser. You can also place
    a script block that needs to be explicitly called by other script code on
    the page using the Page.RegisterClientScriptBlock method.

    The difference is that the latter goes in the top of the page and the
    former goes at the bottom. This is important because inline script
    generally needs to go at the bottom so that the page objects exist before
    it executes. However, regular script must go at the top in case a control
    is referrencing it.

    Best regards,
    yhhuang
    VS.NET, Visual C++
    Microsoft

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Got .Net? [url]http://www.gotdotnet.com[/url]
    --------------------
    !From: "Brian W" <brianw@gold_death_2_spam_rush.com>
    !References: <eDEGn2OQDHA.1024@TK2MSFTNGP12.phx.gbl>
    !Subject: Re: RegisterClientScriptBlock & RegisterStartupScript revisited
    !Date: Wed, 2 Jul 2003 16:04:53 -0700
    !Lines: 70
    !X-Priority: 3
    !X-MSMail-Priority: Normal
    !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    !Message-ID: <ebapd5OQDHA.2700@tk2msftngp13.phx.gbl>
    !Newsgroups: microsoft.public.dotnet.framework.aspnet
    !NNTP-Posting-Host: dsl-107.goldrush.com 206.171.170.107
    !Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
    !Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:31883
    !X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    !
    !Duh! As is often the case, I found the answer about the comment tags after
    I
    !hit send.
    !
    !I would sill like to know about the difference in the 2 methods.
    !
    !
    !Thanks
    !Brian W
    !
    !"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
    !news:eDEGn2OQDHA.1024@TK2MSFTNGP12.phx.gbl...
    !> Sorry to bring these methods up again, but I'm confused...
    !>
    !> I know that one writes the code block just after the <form> and the other
    !> just before the </form>.
    !>
    !> So my question is, what difference does it make? When should one be used
    !as
    !> apposed to the other?
    !>
    !> And, while I'm on the subject of these 2 methods. The documentation for
    !both
    !> says:
    !> "Note Remember to include HTML comment tags around your script so
    !that
    !> it will not be rendered if a requesting browser does not support scripts"
    !>
    !> First of all the example code does not use the HTML comment tags.
    !>
    !> Secondly, when I use the comment tags I get the error "Object expected"
    !from
    !> the java runtime.
    !>
    !> the script when I view source looks like this:
    !>
    !> <!--
    !> <SCRIPT language='javascript'>
    !> function WNS_OpenWindow(url, parms)
    !> {
    !> if (parms=='') parms =
    !>
    !'width=500,height=500,resizable=1,left=10,top=10, toolbar=0,status=0,scrollb
    a
    !> rs=0,menubar=0,location';
    !> newWin = window.open ( url, 'wndNew', parms);
    !> }
    !> </SCRIPT>
    !> -->
    !>
    !> and I use it like this:
    !>
    !> <a id="PageHeaderControl__emailPage"
    !>
    !onclick="WNS_OpenWindow('/project/Tools/Email.aspx?popup=yes&amp;send=http%
    3
    !> a%2f%2flocalhost%2fproject%2fDefault.aspx',
    !> 'height=300,width=475,resizable=yes'); return false; "
    !>
    !href="/project/tools/email.aspx?send=http%3a%2f%2flocalhost%2fproject%2 fDef
    a
    !> ult.aspx">Email this page to a friend</a>
    !>
    !> If I remove the comment tags everything works fine.
    !>
    !>
    !> Thanks for any insight you can offer
    !>
    !> Brian W
    !>
    !>
    !>
    !
    !
    !

    Yan-Hong Huang[MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139