Building a dialog box in that looks like Confirmation box (ASP.NET). Please help !!!

  • Thread starter Thread starter bienwell
  • Start date Start date
B

bienwell

Hi all,

I have a button in aspx file
<asp:button id="Button1" onclick="Button1_Click" runat="server"
Text="Button ..."></asp:button>

Sub Button1_Click(sender As Object, e As EventArgs)
some VB lines of code ....
If condition1 Then
Confirmation Message_1 (Message 1)
If click 'Yes ' Then
Do_Yes1
Else
Do_No1
End If
ElseIf condition2 Then (Message 2)
If click 'Yes ' Then
Do_Yes2
Else
Do_No2
End If

End If

End Sub

I know we cannot get the value return from JavaScript back to VBScript , in
this case, when we pop up confirmation message. Is there other way that we
can build somthing in VB program that looks like a confirmation box in
Javascript which has 2 button 'Yes' and 'No' and perform VB codes when we
click on it ? And the box will be disappear after we click on the button ?
If you have ever do it, please give me your source code.

Many thanks.
 
In your page's Page_Load method...

Button1.Attributes.Add("onclick", "return confirm('Are you sure you want to
do this?');")
 
Try using modal or modeless dialog box. You can call a .aspx page in it.

Regards,
Rohit
 
Hi,

I've tried it already. It worked fine. What I want is to show confirmation
in VB program and get the value returned to do something after that. Also,
Button1.Attributes.Add("onclick", "return confirm('Are you sure you want to
do this?');") always shows a specific message. THis attribute is added for
this button without any condition I want to control. The message sometimes
need to be dynamic !!!
 
I've tried it already. It worked fine.
Excellent!

Also, Button1.Attributes.Add("onclick", "return confirm('Are you sure you
want to do this?');") always shows a specific message. THis attribute is
added for this button without any condition I want to control. The
message sometimes need to be dynamic !!!

Well make it dynamic then! Have you never heard of a variable...?

Dim strMessage As String

strMessage = "Is this your first day?"
Button1.Attributes.Add("onclick", "return confirm('" & strMessage & "');")
 
The text message is in some conditions before I use confirmation message
box. If you see my speudocode, you will know
Button1.Attributes.Add("onclick", "return confirm('" & strMessage & "');")
always added somewhere for this button (usually on Page_load) before you
run the code for this button in on-click event.
What I want is to show the confirmation box in the depending some conditions
inside Button1_click event.
 
Back
Top