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

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

Mark Rae

In your page's Page_Load method...

Button1.Attributes.Add("onclick", "return confirm('Are you sure you want to
do this?');")
 
R

Rohit Kukreti

Try using modal or modeless dialog box. You can call a .aspx page in it.

Regards,
Rohit
 
B

bienwell

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 !!!
 
M

Mark Rae

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 & "');")
 
B

bienwell

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.
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top