How to select a specific client-side sub to run

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
 
C

Craig Deelsnyder

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
 
S

Steven Cheng[MSFT]

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.)
 
G

Guest

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
 
S

Steven Cheng[MSFT]

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.)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top