Return.Confirm vb codebehind in Visual

NeGueSa used Ask the Experts™
I want using javascript "return confirm." in vb codebehind in  Visual get user selected option.
Actually I'm using this in the init Proc of the button
        'cmd.Attributes.Add("onclick", "return confirm('Are you going to \nAdd Multiple Products?');")
Then when the user click the button the confirm dialog appears, if the user click ok there's no problem, but what if the user click cancel? How can I get selected values in the codebehind
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If the user clicks cancel that's that, nothing happens. Say I were to have a button with a Button_Click event defined and also an OnClientClick event (the confirm box). If I click cancel in that confirm box the Button_Click event won't fire. If I click OK, it will.


What I need is if exist any way to retrieve from vb codebehind selected button value in the confirm.window


Let say I want if the user click OK button do "Thing # 1" else do "Thing # 2"  is that possible?
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

there isn't any way because javascript is run on the client and your vb codebehind is run on the server. You may want to call a separate javascript function to save the returned value to a cookie and then retrieve that cookie in the code-behind.


How can I do this?
Create the cookie in javascript:

var ReturnValue = return confirm('Are you going to \nAdd Multiple Products?');
document.cookie="CookieName=" + ReturnValue;

Get the cookie in code-behind:

If Not Request.Cookies("CookieName") Is Nothing Then
      Dim Value As String = Request.Cookies("CookieName").Value.ToString
End If

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial