Solved

alert message in ASP.NET

Posted on 2004-10-13
8
1,546 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to count occurrences of each item in an array.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

840 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