C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Show a confirmation pop up message when a button is clicked


Posted Date: 29 Nov 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: pradiptaMember Level: Gold    
Rating: 1 out of 5Points: 4



ASP.NET makes the life of a web developer is easy. There are several things that we can do with little efforts. But sometimes, we may end up searching Google for a long time to figure out how to do some simple tasks like displaying a confirmation dialog box from ASP.NET.

The following code snippet shows how to display a confirmation dialogbox from ASP.NET:


<script language="javascript">
function ConfirmDelete()
{
var confirmed = window.confirm("You are about to delete a record, would you like to continue ?"
return(confirmed);
}
</script>


Add the following code on the code behind file

ConfirmButton.Attributes.Add("onClick", "return ConfirmDelete();");





Responses

Author: Rajeev     29 Nov 2004Member Level: Silver   Points : 0
Button1.Attributes.Add("Onclick", "return confirm('Are You sure to Delete this Record')").


Author: Sudhir Katiyar    03 Feb 2005Member Level: Bronze   Points : 0
I have two queries.
1. Once i click on the insert button and after meeting certain conditions of the Code behind page this is fired

btnInsert.Attributes.Add("Onclick", "return confirm('PIN is currently assigned to " + strName + " , Would you like to re-assign?');")

but the Pop-up message is coming only after i click the Insert Button again.

Why the Pop-up window is not coming in single click of the insert button.

2. Suppose the user says OK to the POP-uP window than how to capture in Page_Load as the Pop-Up window is with flag OK so that i cud call some method to do the rest according to the functionality of my screen.

Can anyone help me at the earliest

my email id (sudhir.katiyar AT gmail DOT com)






Author: Darious    04 Feb 2005Member Level: Silver   Points : 0
Write the following code in the page_load event

btnInsert.Attributes.Add("Onclick", "return confirm('PIN is currently assigned to " + strName + " , Would you like to re-assign?');")

U need not bother about what user clicks ,When pop up meaasege comes user will have to click ok or cancel .In the javascript u just check if user clicks OK return true else Return false

If true will be returned then the button_click event will be fired else the event will not be fired(The page will not postback)







Author: SS    15 Apr 2005Member Level: Bronze   Points : 0
I'm new to .NET, where do i add ConfirmButton.Attributes.Add("onClick", "return ConfirmDelete();");

in Code behind. I mean in which event should i add this?


Author: Dheeraj    31 Jan 2006Member Level: Bronze   Points : 0
just write this code in pageload ....

id_of_button.Attributes.Add("Onclick", "return confirm('Confirmation message');")


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Concurrency Control Using ADO.NET
Previous Resource: Hide and show Data using Repeater control
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use