Thursday, 18 June 2015

ASP.NET - How to ensure user entered domain name and user name in correct format

Watch this example on YouTUbe:

Copy and paste code below to test (validator highlighted in red)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidateDomainName.aspx.cs" Inherits="WebApplication1.ValidateDomainName" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
            ErrorMessage="Ensure Login ID is in the following format: DomainName\LoginName"

No comments:

Post a Comment