problem when using Confirmation box in ASP.NET program

B

bienwell

Hi all,

I still have a problem when using Confirmation box in ASP.NET program. I
need to get the value return of YES or NO from confirmation box in Sub
function of VB program to do some tasks. For example, I have 2 text boxes
and one button. The button will call On_Click event .

Sub btnSelect_OnClick(ByVal sender As Object, ByVal e As EventArgs)
Dim X as double = CDBL(txtbox1.text)
Dim Y as double = CDBL(txtbox2.text)

If X > Y Then
display confirmation box ("Add $50 to X ? ")
If answer = YES Then X=X+50
Else Do Nothing
End If
Else
display confirmation box ("Subtract $50 to X ? ")
If answer = YES Then X=X-50
Else Do Nothing
End If
End If
End Sub

Can we get the return value of YES / NO from confirmation box with this
pseudocode ? As I know the confirmation will work when you have an event
before clicking the button (e.g in Page_Load
Me.Button1.Attributes.Add("OnClick","return confirm('Are you sure you add
$50 to the X ?');") ) . With this the message is not dynamic.

Can you provide a source code for this ?

Thanks in advance.
 
B

bruce barker \(sqlwork.com\)

no. you have to render the page, with the client script confirm code that
reposts it the user confirms. you might as well redesign and
redirect/transfer to a confirmation page.

-- bruce (sqlwork.com)
 
V

V

Hello,

One really good way that I have always worked with client-side
javascript is to emit it from the control.

Derive the Asp.Net server side button and override the appropriate
methods to insert a Javascript that produces the Confirm Dialogue Box.
This Javascript should contain the code for causing a PostBack from the
button if the user clicks yes, and to do nothing if the user clicks no.

This can be made even more useful, if you add properties in the derived
control that let you specify whether you want to show a confirmation
dialogue box at all, and if yes, then what should the text contain.

This allows for the creation of a re-usable server side control which
can be used as a normal button when needed.

Regards,
Vaibhav
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top