AJAX Extender Example: Button Enabled Changes
page 5 of 7
by Brian Mains
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 18402/ 198

Consumer

I have developed a simplified test page that consumes this new extender. There are two tests; the first test targets a button and sets up the text box as the receiver of the enabled status toggle. Every time the button is clicked, the disabled status flips its state accordingly.

Listing 12

<asp:TextBox ID="txt1" runat="server" />
<asp:Button ID="btn1" runat="server" Text="First Test" CausesValidation="false" 
  UseSubmitBehavior="false" />
<n:ButtonEnabledExtender ID="ext1" runat="server" TargetControlID="btn1" 
  ReceiverControlID="txt1" />

This scenario produces the screenshot below. I produced these screenshots with the tool SnagIt; this is a very popular and very productive tool.

Figure 1

In the second scenario, the extender does not target a textbox as a receiver, it simply defines the button as the target. Notice the ReceiverControlID is not specified.

Listing 13

<asp:TextBox ID="txt2" runat="server" />
<asp:Button ID="btn2" runat="server" Text="Second Test" />
<n:ButtonEnabledExtender ID="ext2" runat="server" TargetControlID="btn2" />

Rather than toggling the textbox enabled status, this test prevents a double-click, as shown below.

Figure 2

In both cases, the script changes the state of some UI element; in the first case, it works with the textbox control, whereas the latter case the button itself. All of this happens on the client side and works seamlessly with JavaScript. Deployment is seamless also because this custom script is stored as an embedded resource in the DLL, and retrieved at runtime. No code is necessary to perform this action.


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 7 and 7 and type the answer here:

User Comments

Title: Reply: how to set data in text box based on ajax autocomple   
Name: Brian Mains
Date: 3/11/2010 3:22:38 PM
Comment:
Hello,

Auto complete has a client-side API; you would have to look to see an event that fires when the first text entry is selected, then set the value for textbox2.

HTH.
Title: how to set data in text box based on ajax autocomple   
Name: ieda
Date: 3/10/2010 4:04:46 AM
Comment:
i have two text box.Texbox1 and textbox2.Both use same table in database.Texbox1 use ajax extender autocomplete to select the data. What can i do if i want textbox2 set data aumatically from database after i select data for textbox1?
Title: Re:Button Extender   
Name: Brian
Date: 10/6/2008 3:08:21 AM
Comment:
I tested the code but i cannot achieve your test2 result.
Title: thanks   
Name: Karthikeyan
Date: 9/24/2008 7:54:24 AM
Comment:
Nice article.
Title: thanks   
Name: rezagolab
Date: 9/24/2008 3:10:50 AM
Comment:
hi
thanks
Title: Re:Button Extender   
Name: NamNguyenLe
Date: 8/28/2008 10:15:30 PM
Comment:
Thanks for cool article.
But it will be better if code is avaiable.
Please post it please.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2010 ASPAlliance.com  |  Page Processed at 3/22/2010 4:28:41 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search