Solved

alert message in ASP.NET

Posted on 2004-10-13
8
1,549 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
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.

632 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