RegisterStartUpScript

Discussion in 'ASP .Net' started by BillGatesFan, Jun 23, 2008.

  1. BillGatesFan

    BillGatesFan Guest

    If I click a button and have a function that registers a startup
    script like
    button_click event:

    ClientScript.RegisterStartupScript(GetType(Page), "gArray", "var
    DAddresses = new Array(1,2,3);", True)



    Then I have in my head tag


    <script type="text/javascript">

    var DAddresses = null;
    function initialize() {
    alert(DAddresses);
    if (DAdresses)
    showAddress(DAddresses);

    }

    function showAddress(address) {
    alert(address);
    ....
    }
    </script>


    I'm trying to create an javascript array on the server to be used by
    my client-side javascript on postback
    BillGatesFan, Jun 23, 2008
    #1
    1. Advertising

  2. BillGatesFan

    bruce barker Guest

    ClientScript.RegisterStartupScript add it script right after the <form
    runat=server> tag. this means that function and variables are not available
    to inline code in the <head>. your client javascript should not access server
    generated code until onload.


    -- bruce (sqlwork.com)


    "BillGatesFan" wrote:

    > If I click a button and have a function that registers a startup
    > script like
    > button_click event:
    >
    > ClientScript.RegisterStartupScript(GetType(Page), "gArray", "var
    > DAddresses = new Array(1,2,3);", True)
    >
    >
    >
    > Then I have in my head tag
    >
    >
    > <script type="text/javascript">
    >
    > var DAddresses = null;
    > function initialize() {
    > alert(DAddresses);
    > if (DAdresses)
    > showAddress(DAddresses);
    >
    > }
    >
    > function showAddress(address) {
    > alert(address);
    > ....
    > }
    > </script>
    >
    >
    > I'm trying to create an javascript array on the server to be used by
    > my client-side javascript on postback
    >
    bruce barker, Jun 23, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian W
    Replies:
    1
    Views:
    2,916
    Yan-Hong Huang[MSFT]
    Jul 4, 2003
  2. bruce barker
    Replies:
    1
    Views:
    494
    Dave Stienessen
    Jul 31, 2003
  3. Mark
    Replies:
    1
    Views:
    548
    Natty Gur
    Oct 16, 2003
  4. Earl Teigrob

    Using Page.RegisterStartupScript in Class

    Earl Teigrob, Feb 3, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    5,504
    Earl Teigrob
    Feb 3, 2004
  5. Lukman

    RegisterStartupScript

    Lukman, Feb 18, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    10,522
    gvdamn
    Jun 24, 2010
Loading...

Share This Page