Solved

alert message in ASP.NET

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope‚Ķ
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.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now