RequiredFieldValidator , ValidationSummary

One of my readers asked me to write about validation summary of ASP.NET 2005.

A small example to help those who never used validate summary before.

I am using validationsummary control and RequiredFieldValidator to let you guys understand. 

Brief introduction:

Validation Summary:
The ValidationSummary control is used to display a summary of all validation errors  occurred in a Web page.

The error message displayed in this control is specified by the ErrorMessage  property of each validation control. If the ErrorMessage property of the validation  control is not set, no error message is displayed for that validation control.

For more detail click here.

RequiredFieldValidator:

The RequiredFieldValidator control is used to make an input control a required field.

For more detail click here

 Use below code,copy it and test at your webpage.

<table width=”100%” cellpadding=”1″ cellspacing=”6″>            <tr>                <td>                    <asp:ValidationSummary ID=”ValidationSummary1″ runat=”server” ShowSummary=”true” />                </td>            </tr>            <tr>                <td>                    <table>                        <tr>                            <td>                                <asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox></td>                            <td>                                <asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ControlToValidate=”TextBox1″                                    ErrorMessage=”Missing field One” SetFocusOnError=”True” Display=”None”> </asp:RequiredFieldValidator></td>                        </tr>                        <tr>                            <td>                                <asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox></td>                            <td>                                <asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ runat=”server” ControlToValidate=”TextBox2″                                    Display=”none” ErrorMessage=”Missing field two” SetFocusOnError=”True”></asp:RequiredFieldValidator></td>                        </tr>                        <tr>                            <td align=”center” colspan=”2″>                                <asp:Button ID=”Button1″ runat=”server” Text=”Submit” /></td>                        </tr>                    </table>                </td>            </tr>

        </table>

For any further help, write me.

Rana

About these ads

2 thoughts on “RequiredFieldValidator , ValidationSummary

  1. The artical on Validation Summary and RequiredFieldValidator is very informative.
    Also write something about Image and Text Verification on registration form.
    Advance Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s