Hi Al
Might I suggest that perhaps you are closer than you think?
RegisterStartupScript can be used all by itself to accomplish what you want.
You don't have to dynamically set the OnLoad attribute of the <body>
element. Remember that RegisterStartupScript not only can dynamically add
script to your page, but it can be used to immediately execute JavaScript
(i.e., instruct the client execute it immediately upon receipt). Try putting
the following code at the end of your server-side routine that updates your
database:
string scriptString = "<script language=JavaScript>ShowConfirm();</script>";
if(!this.IsClientScriptBlockRegistered("clientScri pt1")){
this.RegisterStartupScript("clientScript1", scriptString);
}
Note: I have not tested this code - rather I pulled some working code that
does something similar to what you need and modified it to include your
ShowConfirm() call. It might need to be tweaked...
-GH
"Al Cadalzo" <ca*****@hotmail.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
I want to respond to a submit button click on a form by writing to a
database then display a popup confirmation window that just has a
'Success' message and an OK button on it that returns the user to the form.
I've been playing with the RegisterStartupScript method to register my
javascript that opens a modal window that has the 'success' message. I'm
creating the <script language=javascript> block just fine. It contains a
function ShowConfirm(). How do I dynamically set the OnLoad attribute of
the <body> element to "javascript: ShowConfirm()" so that the confirmation
window displays after I do my processing in the OnClick event handler of
my button?
I'm using this code:
DirectCast(Me.FindControl("Body"),
HtmlContainerControl).Attributes("OnLoad") = "javascript:ShowConfirm()"
Is this the best way? Any suggestions?
Thanks,
Al