Solved

alert message in ASP.NET

Posted on 2004-10-13
8
1,547 Views
Last Modified: 2010-05-18
Hi,
I'm using a web form  form with three text boxes and two buttons(Confirm,Cancel)

What  I need is when Users Click Confirm button , I need to display a meesage box with message and  Ok and Cancel buttons

Do you want to continue .If yes Click Ok button or Click Cancel button.

when users Click on Ok button on the mesage box , I need to submit the form and when Cancel is Clicked ,Redirect the form to other page.

I'm using server side validation in the Confirm button

Thanks
0
Comment
Question by:AnithaB
  • 3
8 Comments
 
LVL 6

Expert Comment

by:margant
ID: 12300801
Hi,

You can use OnClick property of the button <asp:Button OnClick=".."


For Confirm
onclick="return confirm('Are you Sure?');"

For Cancel
onclick="window.location.href = www.ursite.com;"

Best of luck,
-AM
0
 
LVL 6

Expert Comment

by:margant
ID: 12300827
For Cancel button,  u can also use
location.replace("http://www.yahoo.com");
instead of "window.location.href = www.ursite.com;"

-AM
0
 

Expert Comment

by:daveh541
ID: 12301761
0
 

Author Comment

by:AnithaB
ID: 12302134
I'm talking about the Cancel button in the message box not in the form.

Let me explain to you,

 I have a form with Confirm and Cancel buttons.

If Confirm button is clicked ,then I need to display a message box with two buttons Ok and Cancel.

If Ok on Message box is pressed ,then form to be submitted.
If Cancel on message box is pressed ,then Redirect to a differeent page.

Any help.
Thanks
0
 
LVL 6

Accepted Solution

by:
margant earned 500 total points
ID: 12302739
Here is the code for the whole page

<html>
<head>
<script type="text/javascript">
      function btnClick ()
      {
            var agree=confirm("Are you sure?");
            if (agree)
            {
                        document.form1.submit();
                        return true
            }
            else
            {
                  document.location.href="www.yahoo.com";
                  return false
            }
      }
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form ID="form1" name="form1" action="login.htm" method="post" onSubmit="return btnClick()">
  <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

Best of luck,
AM
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question