Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the files( Test.aspx ,Test.aspx.vb). The button in Test.aspx. The button name is " Calculate". When the user click on "Calculate" button on client site, the dialog will show . In the dialog will have two button , one is will be apply button, one is cancel. But user will click the apply button.
i will do some thing, if user click cancel , I will do difference thing then close the dialog.
How can I appy your code in my project. In the Test.aspx has alot o textfield , i will get data from there then update to database.
Thank you very much
Jenny.
Posted

Ok, what you have to do is handle this client side with javascript. Start off with the javascript method:

<script type="text/javascript">
function PopupConfimBox() {
    var confirmBox = confirm("My Question here");
    if (confirmBox == true) {
        //If they clicked ok, do what you need to do!
        return (true / false); 
        //return true if you want the page to post back and false if you dont!
    }
    else {
        //If they clicked ok, do what you need to do!
        return (true / false);
        //return true if you want the page to post back and false if you dont!
    }
}
</script>


Ok, now link this up with your ASP button in the OnClientClick event!

<asp:button id="btnMyMagicButton" runat="server" onclientclick="return PopupConfirmBox()" clientclick="MyServerSideMethod()" text="Click Me!" xmlns:asp="#unknown" />


Your server side method will only be called if your client side (javascript) method returns true.
 
Share this answer
 
Can I get the value of the textfield and save to the database in
C#
if (confirmBox == true) {// in here? }


Thanks
 
Share this answer
 
Comments
DominicZA 21-Jul-11 18:00pm    
Rather add a comment to the answer instead of adding another solution! Yes, you can! You will just put the "save to database" code in the server method I mentioned above!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900