Technology Networking & Internet

How to Use Confirmation With ASP Buttons

    • 1). Open Visual Studio.NET and click "File."

    • 2). Select "New Website," then double-click "ASP.NET Web Site" to create a new website project. Visual Studio will place the project files in the Solution Explorer on the right side of the window.

    • 3). Locate "Default.aspx" in the solution explorer.

    • 4). Double-click "Default.axpx." The file's code will appear in the editing window.

    • 5). Click the "Design" button at the bottom of the window to switch to design view. In this view, you can see the Web page as it will appear in a browser.

    • 6). Click "View" and select "Toolbox." Double-click "Label." Visual Studio will add a label to the page.

    • 7). Return to the toolbox and double-click "Button." A button will appear on the page next to the label. Double-click that button. Visual Studio will create an event handler and display its code in the editor. The code will look like this:

      protected void Button1_Click(object sender, EventArgs e)

      {

      this.Label1.Text = "Processing Button Click";

      }

      This code sets the label's text to "Processing Button Click" when you click the button.

    • 8). Return to the Solution Explorer on the right side of the window and double-click "Default.aspx." Click the "Source" tab at the bottom of the window to view the file's source code.

    • 9). Locate this line of code in the editing window:

      <asp:Button runat="server" onclick="Button1_Click" Text="Button" />

      This code creates the button.

    • 10

      Modify the code so that it looks like this:

      <asp:Button runat="server" onclick="Button1_Click" Text="Button"

      OnClientClick="return confirm('Continue with this operation?');" />

      The code is the same except for the "OnClientClick" property appended to the end of the line. This property causes the browser to open a JavaScript "confirm" window when you click the button.

    • 11

      Press "F5" to run the project. Your browser will open and display the label and the button. Click the button next to the label. A pop-up window will open and display "Continue with this operation?" It will also display two confirmation buttons labeled "Yes" and "No."

    • 12

      Click the "No" confirmation button. The confirmation window will close and nothing will happen. This occurs because you canceled the post back to the Web server by answering "No" in the confirmation window.

    • 13

      Click the button next to the label again. The confirmation window will reopen. Click the "Yes" confirmation button this time. The browser will continue and send a request to the server. The server will then send back a response and cause the code in the event handler to run. This code will set the contents of the label to "Processing Button Click."

SHARE
RELATED POSTS on "Technology"
What Can You Do to Prevent Link Rot?
What Can You Do to Prevent Link Rot?
What Makes a Phone Line DSL Enabled?
What Makes a Phone Line DSL Enabled?
Boost And Maintain Your Squeeze Page SERP Ranking By Turning It Into A Squeeze Blog
Boost And Maintain Your Squeeze Page SERP Ranking By Turning It Into A Squeeze Blog
Define RocketMail
Define RocketMail
How NOT to market on FaceBook and committ social blunders
How NOT to market on FaceBook and committ social blunders
Check Out These Ideas About Technology Blogging
Check Out These Ideas About Technology Blogging
How to Watch an Item on eBay
How to Watch an Item on eBay
Totally Dumb Copywriting Mistakes To Avoid
Totally Dumb Copywriting Mistakes To Avoid
How to Edit a MySpace Music Profile
How to Edit a MySpace Music Profile
Backlink Energizer Assessment
Backlink Energizer Assessment
Apple iPhone 5 With An Increase Of Additional Features
Apple iPhone 5 With An Increase Of Additional Features
Online Marketing Consultant
Online Marketing Consultant
How Social Bookmarking Can Be Advantageous For Your Website
How Social Bookmarking Can Be Advantageous For Your Website
How to Check My IP for a Blacklist
How to Check My IP for a Blacklist
Which Is Better: Internal or External Modem Software or Hardware?
Which Is Better: Internal or External Modem Software or Hardware?
Attention Empower Newtork Seekers
Attention Empower Newtork Seekers
Free of charge Casino Video games - The On the net Casino Bonus
Free of charge Casino Video games - The On the net Casino Bonus
Why Digital Marketing Should Be Just What The Doctor Ordered
Why Digital Marketing Should Be Just What The Doctor Ordered
Marketing Online Through Social media Marketing Service
Marketing Online Through Social media Marketing Service
Working With The Right SEO Providers
Working With The Right SEO Providers
How To Share a Desktop
How To Share a Desktop
Why Pay for Deutsche Post Secure Email?
Why Pay for Deutsche Post Secure Email?
SMO Company in India – The Best Option for Cost-Effective Online Brand Promotion
SMO Company in India – The Best Option for Cost-Effective Online Brand Promotion

Leave Your Reply

*