473,378 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Finally found how to display confirm dialog box

Wow. I finally found out the easiest way to display a yes/no (well,
yes/cancel) dialog pop up from ASP.Net.
Turnes out to be really easy. Just add the following in you Page_Load
method (C# code behind):

if(!IsPostBack)
{
DeleteUserBtn.Attributes.Add("onclick", "return confirm('Are you sure
you want to Delete?')");
}

Replace DeleteUserBtn with the name of your asp.net button (or
whatever control you want).

This will assign javaScript to that button to return the result of
displaying the confirm dialog. If user clicks yes, then it returns
true and the buttons code-behind method will be called. Otherwise a
post-back won't occur and the code-behind will not be run!!

This method can be used to call any javaScript function you may have
already defined.

I hope someone can find this info useful and it saves someone some
time.

Tony.

P.S. If you are writing an ASP.Net program and you don't know
JavaScript, you are limiting yourself a lot! Spend an 30 mins or so
doing this tutorial to give yourself some idea of the power it can
provide:
http://www.w3schools.com/js/default.asp
Nov 18 '05 #1
0 2543

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Doug O'Leary | last post by:
Hey, all; Apparently, I'm missing the concept. I'm writing a web app in perl to manage nagios configuration files. One of the things I'd like to do is to confirm an update via a popup window...
1
by: Billy | last post by:
Hi... I have a problem with a confirm dialog box. I want to execute some code and then prompt the user with a confirm dialog box who's message will depend on the result of the execution from...
2
by: JerryK | last post by:
I have a piece of asp.net code that sets up a call to a javascript function in a controls onclick event. This javascript function displays a confirm dialog and returns the results of the confirm...
3
by: ad | last post by:
I can only use the OnClientClick event of a button to show a confirm dialog like: OnClientClick="return confirm('Are you sure?');" Can we show the confirm dialog by progrm, net triggered by a...
8
by: rn5a | last post by:
I have gone through a no. of posts in this NewsGroup regarding my problem but alas, couldn't come across one which would have helped me in resolving the issue. My problem is this: An ASPX Form...
5
by: strikefiend | last post by:
Ok, I'm somewhat new to .NET C# language and am having a bit of trouble. I'm trying to run the javascript confirm() method from my ascx page but I'm currently using C# as the main language of the...
13
by: MikeC | last post by:
I read in the book Javascript The Definitive Guide by David Flanagan the following in reference to the use of alert, confirm, and prompt. "Although these dialog methods are extremely simple and...
1
by: =?Utf-8?B?UmFq?= | last post by:
In my user control, I have included javascript code using ScriptManager.RegisterClientScriptBlock(). JavaScript code has a confirm message dialog box and we store the message value in a hidden...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.