0

Hi,
I am writing a web site in vb.net.
I need to show javascript confirm box before data is inserted. so if cancel is pressed program flow stops, otherwise data is inserted.
quick help will be much appreciated !! :)

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Shantanu88d
0

i will assume that you are using a asp.net control button for this.

<asp:Button ID="btnSave" runat="server" OnClick="Server_btnSave_Click" OnClientClick="Client_btnSave_Click" Text="Save" />

now you can add in your codebehind the Server_btnSave_Click method and in javascript write your method for Client_btnSave_Click, that way when the user click the button the first thing to run is the client side script and there you will have your confirm statement, and the workflow will continue depends on what the user click, ok or cancel...

0

hey, thanks, got it. but I got another doubt. Suppose I want to do some further processing depending on user's response. Like, I want to take user to some other page if he hits cancel, then what do you suggest I should do ?

0

you can know what the user click, the confirm method return true if the button press was Ok, so you can have something like

if(Confirm("Are you sure want to insert this?") == false)
{
   //method for false
}

you can assign the return to a var too and then do whatever you need

var a = Confirm("are you sure about this?");
if(a == true)
   //if click ok
else
   //if click cancel

hope that helps

Edited by jbisono: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.