Thank you, Kevin, for your reply. I tried to look at the documation and
exmples for Page.RegisterStartupScript, but I don't think I really
understand how I can adapt it to my case.
I have the following code behinde page (all the checks are simplified) which
is perfectly working fine. What I would like to do is to replace the error
messages (lblError) with a popup page (popup.htm).
Would it be possible ?
Thank you,
Kiyomi
********************* vb *************************
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
CheckRules()
End Sub
Private Function CheckRules()
If txtInput.Text = "" Then
lblError.Text = "You must enter your age"
Return False
Exit Function
End If
If IsNumeric(txtInput.Text) Then
'do nothing
Else
lblError.Text = "The format is not correct"
Return False
Exit Function
End If
If Convert.ToInt16(txtInput.Text) < 20 Or
Convert.ToInt16(txtInput.Text) > 60 Then
lblError.Text = "Your age must between 20 and 60"
Return False
Exit Function
End If
lblConfirm.Text = "The information has been registered"
Return True
End Function
*************************** HTML **********************
<script>
function doDialog()
{
if (Form1.lblError.value != "" )
{ var x=showModalDialog('popup.htm', Form1.lblError.value,
'status:no;resizable:yes'); }
}
</script>
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I'm not sure I understand you fully. It sounds like you have a Button
Control that causes a server-side Click event to happen. The event handler
performs some processing, and you want to add a JavaScript popup window to
the page afterwards. Am I following you so far?
The place where I lose you is where you talk about not using the Click
event handler to add the JavaScript to the page. The JavaScript to open the
Popup window would be added on the server side, and all of the information you
need to display in the popup window should be available at the end of your
event handler method. So, all you need to do is add the JavaScript to the
Page at the end of the event handler, using Page.RegisterStartupScript.
What is the problem?
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
"Kiyomi" <k.*******@unesco.org> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl... 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