Hello,
I have some codes under event ButtonSend_Click to check the user input
values. This check is complicated enough using different stored procedures.
Then according the result of the checks, I would like to display a popup
page in which the user can select "OK", "Cancel" etc.
Now I created a javascript function doDialog() in HTML page to open a popup
page. I would like to call this function from the code behind page. I
cannot use onclick event with ButtonSend because I have lots of checks to do
before calling doDialog() function and this function should be called only
under certain test results. Also, I have to carry as a parameter different
message texts depending on the test results to display on the popup page.
Thank you for your kind advice,
Kiyomi
Rashad Rivera - 09 Jan 2006 06:54 GMT
Kiyomi,
I don't quite understand your question, but if you want to display a
modal dialog to the client (triggered from the server-side code), then the
best way to go about this is to create a simple JavaScript function on a
global JS file that all your forms include. Then call this function form
your server side and pass in the crucial parameters like URL to the dialog
form, width, and height. Sample code below and I hope this helps.
- Rashad Rivera <spam@omegusprime.com>
www.omegusprime.com
=====
myForm.cs code
...
private void Page_Load(object sender, System.EventArgs e) {
...
if (isTimeToShowDialog) {
this.RegisterStartupScript("someUniqueName",
"myJSDialogMethod('/theDialogForm.aspx', 450, 300);");
}
...
}
=========
client side: global.js
...
function myJSDialogMethod(url, width, height) {
return
window.showModelessDialog(url,null,'dialogHeight:'+height+'px;dialogWidth:'+width+'px;edge:Raised;center:Yes;help:No;resizable:No;status:No;');
}
> Hello,
>
[quoted text clipped - 17 lines]
>
> Kiyomi
Kiyomi - 09 Jan 2006 09:18 GMT
Thank you for your kind advice.
I managed to make my popup work, using RegisterStartupScript as follows.
Now, I wish to retrieve user's response (OK or Cancel) and depending on
the response, I wish to continue different processes. Would you please
advice me how I can do this ?
Thank you very much.
My HTML page
function doConfirm(msg) {
var x=showModalDialog('Confirm.htm', msg, 'status:no;resizable:yes');
}
My VB code behind page
Function CheckRules()
Dim msg as String
msg = ?An error is detected. Do you want to continue processing ? ?
If (Not Me.IsStartupScriptRegistered("Startup")) Then
Me.RegisterStartupScript("Startup", "<script>doConfirm('" & msg &
"');</script>")
End If
----- After running doConfirm(msg) This is what I wish to do --------
If doConfirm(msg) returns True (i.e., user clicks OK button)
Continue processing below
Else (i.e., user clicks Cancel button)
Return False
Exit Function
End if
----- Continue processing
Return True
End Function