The AsyncButton is one of three AsyncWebControls that provides you with a simple interface that allows you to control each AsyncCallback and sort.
<%@ Register Assembly="AsyncControls" Namespace="DelvingWare.AsyncControls" TagPrefix="dw" %> <dw:AsyncButton runat="server" ID="btVisible" CssClass="greyButton" OnClick="btVisible_Click" Text="Hide AsyncButton" /> <dw:AsyncButton runat="server" ID="btEnable" CssClass="greyButton" OnClick="btEnable_Click" Text="Disable AsyncButton" /> <p /> <dw:AsyncButton runat="server" ID="btMain" OnClick="btMain_Click" Text="AsyncButton" />
using System; using DelvingWare.AsyncControls; ... protected void btMain_Click( object sender, AsyncEventArgs ae ) { // change the button text btMain.Text = "Clicked the AsyncButton"; } protected void btVisible_Click( object sender, AsyncEventArgs ae ) { // change the visibility btMain.Visible = !btMain.Visible; // update the AsyncButton text if ( btMain.Visible ) btVisible.Text = "Hide AsyncButton"; else btVisible.Text = "Show AsyncButton"; } protected void btEnable_Click( object sender, AsyncEventArgs ae ) { // upate the enabled state btMain.Enabled = !btMain.Enabled; // update the AsyncButton text if ( btMain.Enabled ) btEnable.Text = "Disable AsyncButton"; else btEnable.Text = "Enable AsyncButton"; }
Imports System Imports DelvingWare.AsyncControls ... Protected Sub btMain_Click(ByVal sender As Object, ByVal ae As AsyncEventArgs) ' change the button text btMain.Text = "Clicked the AsyncButton" End Sub Protected Sub btVisible_Click(ByVal sender As Object, ByVal ae As AsyncEventArgs) ' change the visibility btMain.Visible = Not btMain.Visible ' update the AsyncButton text If btMain.Visible Then btVisible.Text = "Hide AsyncButton" Else btVisible.Text = "Show AsyncButton" End If End Sub Protected Sub btEnable_Click(ByVal sender As Object, ByVal ae As AsyncEventArgs) ' upate the enabled state btMain.Enabled = Not btMain.Enabled ' update the AsyncButton text If btMain.Enabled Then btEnable.Text = "Disable AsyncButton" Else btEnable.Text = "Enable AsyncButton" End If End Sub
.asyncButton { border: 0px; background-image: url("images/greyButton.gif"); background-repeat: no-repeat; width: 120px; height: 25px; } .asyncButton:hover { background-image: url("images/greyButtonHov.gif"); background-repeat: no-repeat; cursor: pointer; }