Type in the above AsyncTextBox.
The AsyncTextBox you with an Async-Enabled text box server control, that features internal multi-validation.
<%@ Register Assembly="AsyncControls" Namespace="DelvingWare.AsyncControls" TagPrefix="dw" %> <dw:AsyncTextBox runat="server" ID="txtMain" Size="50" MaxLength="50" OnTextChanged="txtMain_TextChanged" /> <dw:AsyncLabel runat="server" ID="lblMain" RenderMode="paragraph">Type in the above AsyncTextBox.</dw:AsyncLabel>
using System; using DelvingWare.AsyncControls; ... protected void txtMain_TextChanged( object sender, AsyncEventArgs ae ) { // get the length of the text if ( txtMain.Text.Length >= 50 ) { // update the AsyncLabel to show demo limit lblMain.Text = "You are limited to 50 chars or less in this demo."; return; } // if the AsyncTextBox text is empty (null or all whitespace) if ( AsyncHelpers.IsEmpty(txtMain) ) lblMain.Text = "Nothing..."; else lblMain.Text = "You've typed: "+ txtMain.Text; }
Imports System Imports DelvingWare.AsyncControls ... Protected Sub txtMain_TextChanged(ByVal sender As Object, ByVal ae As AsyncEventArgs) ' get the length of the text If (txtMain.Text.Length >= 50) Then ' update the AsyncLabel to show demo limit lblMain.Text = "You are limited to 50 chars or less in this demo." Return End If ' if the AsyncTextBox text is empty (null or all whitespace) If AsyncHelpers.IsEmpty(txtMain) Then lblMain.Text = "Nothing..." Else lblMain.Text = ("You've typed: " + txtMain.Text) End If End Sub