DotNet Tutorials

V4 Dot Net Tutorials

Server Intellect Cloud Hosting

 AJAX Confirm Button Extender

This tutorial will teach you how to create and use an AJAX Confirm Button Extender
Introduction
In This tutorial we will Learn how to Create and Use a Confirm Button Extender.  

Step 1. Create the Web Form

1. start by Creating a new Web form and naming it "Default.aspx" 
2. Create a Button and a Label on the form named "Button1" and "Label1"
3. Add an AJAX Script Manager to the Form so that we can use AJAX Controls
4. Add the Confirm Button Extender to the button by clicking the Smart tag and selecting Add Extender
5. Now the Web Form is complete, but it is not read to be run yet.

I just signed up at Server Intellect and couldn't be more pleased with my Fully Scalable & Redundant Cloud Hosting! Check it out and see for yourself.

	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
	<br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
	<br />
	<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
	<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
	<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
	Text="Button" /> <asp:ConfirmButtonExtender ID="Button1_ConfirmButtonExtender" 
	runat="server" ConfirmText="Click OK to make the Label say OK or click Cancel to
	Cancel the Operation" Enabled="True" TargetControlID="Button1">
</asp:ConfirmButtonExtender>
</ContentTemplate>
</asp:UpdatePanel>

</div>
</form>
</body>
</html>
Step 2. Create the Code Behind
1.  Double click on the Button Control in the Design View to open up the Code window
2. Enter the Code Below, this code would normally make the Label say OK every time you click the button, however the code in the front end only lets it run once you confirm. 
3. Once this code is in you can go ahead and run the project and see how it works.

We used over 10 web hosting companies before we found Server Intellect. Our new cloud server,was set up in less than 24 hours. We were able to confirm our order over the phone. They responded to our inquiries within an hour. Server Intellect's customer support and assistance are the best we've ever experienced.

	protected void Button1_Click(object sender, EventArgs e)
        {
            
            Label1.Text = "you clicked OK";
        }
		

We moved our web sites to Server Intellect and have found them to be incredibly professional. Their setup is very easy and we were up and running in no time.

Conclusion
In This Tutorial we Learned how to Create and Use a Confirm Button Extender in AJAX.  This button can be used to warn people of what a button does once they press it.  This control is used in lots of websites and it is easy to setup and use.