How to select a specific client-side sub to run

Discussion in 'ASP .Net' started by =?Utf-8?B?U3Vl?=, Nov 18, 2004.

  1. ASP.NET web page: get info from user via web server controls, user clicks web
    server button when happy with new values, code behind sub grabs the data and
    updates a SQL database. At this point, I would like to display a msgbox/alert
    to the user indicating success or failure of the database update. I am
    familiar with registering client-side script blocks and assigning them to
    buttons, etc via an attribute assignment in the itemdatabound sub. But how
    can I specify which client-side script to call depending on the database
    update results and how would I call it from the server side? Or is what I
    would like to do not possible?

    tia,
    Sue
     
    =?Utf-8?B?U3Vl?=, Nov 18, 2004
    #1
    1. Advertising

  2. On Wed, 17 Nov 2004 16:08:02 -0800, Sue <> wrote:

    > ASP.NET web page: get info from user via web server controls, user
    > clicks web
    > server button when happy with new values, code behind sub grabs the data
    > and
    > updates a SQL database. At this point, I would like to display a
    > msgbox/alert
    > to the user indicating success or failure of the database update. I am
    > familiar with registering client-side script blocks and assigning them to
    > buttons, etc via an attribute assignment in the itemdatabound sub. But
    > how
    > can I specify which client-side script to call depending on the database
    > update results and how would I call it from the server side? Or is what I
    > would like to do not possible?
    >
    > tia,
    > Sue


    So, you want to do it as the page loads? Because you update the DB on the
    server (during server postback processing)..then just register a call via
    javascript to run at page load using:

    http://msdn.microsoft.com/library/d...mwebuipageclassregisterstartupscripttopic.asp

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
     
    Craig Deelsnyder, Nov 18, 2004
    #2
    1. Advertising

  3. Hi Sue,

    As Craig has mentioned, the Page.RegisterStartupScript can help render out
    a script block. If you just need display different javascript alert
    message depending on the processing result at serverside(codebehind), I
    think we can make a helper function like:


    public const string SCRIPT_MSGBOX = "<script
    language='javascript'>alert('{0}');</script>";

    private void DisplayMessageBox(string msg)
    {

    Page.RegisterStartupScript("msgbox_script",string.Format(SCRIPT_MSGBOX,msg))
    ;
    }

    Then, we can call the "DisplayMessagebox" with different message param
    after our database update processing. How do you think?

    If there is any other concerns , please feel free to post here. Thanks.

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Nov 18, 2004
    #3
  4. Steven (and Craig), I think this is just what I'm looking for. I'll give it a
    try today and let you know. Thanks! Sue

    "Steven Cheng[MSFT]" wrote:

    > Hi Sue,
    >
    > As Craig has mentioned, the Page.RegisterStartupScript can help render out
    > a script block. If you just need display different javascript alert
    > message depending on the processing result at serverside(codebehind), I
    > think we can make a helper function like:
    >
    >
    > public const string SCRIPT_MSGBOX = "<script
    > language='javascript'>alert('{0}');</script>";
    >
    > private void DisplayMessageBox(string msg)
    > {
    >
    > Page.RegisterStartupScript("msgbox_script",string.Format(SCRIPT_MSGBOX,msg))
    > ;
    > }
    >
    > Then, we can call the "DisplayMessagebox" with different message param
    > after our database update processing. How do you think?
    >
    > If there is any other concerns , please feel free to post here. Thanks.
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
     
    =?Utf-8?B?U3Vl?=, Nov 18, 2004
    #4
  5. Steve, this worked beautifully. Thank you!

    Sue

    "Steven Cheng[MSFT]" wrote:

    > Hi Sue,
    >
    > As Craig has mentioned, the Page.RegisterStartupScript can help render out
    > a script block. If you just need display different javascript alert
    > message depending on the processing result at serverside(codebehind), I
    > think we can make a helper function like:
    >
    >
    > public const string SCRIPT_MSGBOX = "<script
    > language='javascript'>alert('{0}');</script>";
    >
    > private void DisplayMessageBox(string msg)
    > {
    >
    > Page.RegisterStartupScript("msgbox_script",string.Format(SCRIPT_MSGBOX,msg))
    > ;
    > }
    >
    > Then, we can call the "DisplayMessagebox" with different message param
    > after our database update processing. How do you think?
    >
    > If there is any other concerns , please feel free to post here. Thanks.
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
     
    =?Utf-8?B?U3Vl?=, Nov 18, 2004
    #5
  6. You're welcome Sue,

    I'm also glad to assist you.
    Have a good day!

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Nov 19, 2004
    #6
    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. Azmarae
    Replies:
    1
    Views:
    555
    Carlos Campos
    Mar 3, 2004
  2. Guadala Harry
    Replies:
    4
    Views:
    1,545
    =?Utf-8?B?aGFyaSBwcmFzYWQ=?=
    Jun 15, 2004
  3. aa
    Replies:
    1
    Views:
    350
    Joaquin Corchero
    Mar 8, 2005
  4. Ben
    Replies:
    2
    Views:
    955
  5. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,168
    Lawrence D'Oliveiro
    May 20, 2011
Loading...

Share This Page