How to select a specific client-side sub to run

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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 (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
 
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.)
 
Back
Top