Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

alert message in ASP.NET

Posted on 2004-10-13
8
Medium Priority
?
1,551 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
5 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
 

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 2000 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

Independent Software Vendors: 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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.
Suggested Courses

772 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