JavaScript: Confirm User Action Script

Code:

<script language="javascript" type="text/javascript">
    function ConfirmDeleteSomething() {
        return confirm("Warning: This Something will be permanently deleted. Would you still like to continue? ");
    }



<asp:LinkButton ID="lbtnDelete" runat="server" 
    OnClick="lbtnDelete_Click"
    CausesValidation="false"
    OnClientClick="return ConfirmDeleteSomething()">Delete Something

Summary:

To make sure that a user is actually sure they want to perform an unrecoverable action, such as deleting something, you may want to add a confirmation dialog warning the user of what their potential actions may do.

To do this using JavaScript simply add a function which calls the ‘confirm’ command and call that function through the ‘OnClientClick’ event of your button control in ASP.net.

Published by

Tim Clark

Experienced Business Owner, Chief Information Officer, Vice President, Chief Software Architect, Application Architect, Project Manager, Software Developer, Senior Web Developer, Graphic Designer & 3D Modeler, University Instructor, University Program Chair, Academic Director. Specialties: Ruby, Ruby on Rails, JavaScript, JQuery, AJAX, Node.js, React.js, Angular.js, MySQL, PostgreSQL, MongoDB, SQL Server, Responsive Design, HTML5, XHTML, CSS3, C#, ASP.net, Project Management, System Design/Architecture, Web Design, Web Development, Adobe CS6 (Photoshop, Illustrator)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s