Hi,
I have created a registeration page without using login controls in asp.net (C#). I have taken label,text boxes and validation controls. Can u please help me, i dont know how to validate them or how this will work. Its very urgent

Thankx

Recommended Answers

All 14 Replies

This is a little vague. Are you trying to verify that the user is valid? Or are you trying to make sure the credentials they enter, e-mail address for username etc., are valid?

If you are looking to validate the user, you will need to query a database for authenticated users. If the information given in the text boxes matches, you allow the user to log in, otherwise you don't.

Please provide us some more information, about what exactly are you trying to validate.

Thanx for replying.

I want to validate the user as well as i want to check credentials they enter, e-mail address for username are valid? So what kind of query is required. Can u plz. tell me where will i use membership class in this.

Do you want validator using ajax r what?
If any possible provide your code please...

<asp:RequiredFieldValidator ID="rfvTo" runat="server" ErrorMessage="Please enter To Address" Display="None" ControlToValidate="txtTo" SetFocusOnError="true"></asp:RequiredFieldValidator>                                       
      <asp:ValidatorCalloutExtender ID="vceTo" runat="server" Enabled="True" TargetControlID="rfvTo"></asp:ValidatorCalloutExtender>
                                        
      <asp:RegularExpressionValidator ID="revTo" runat="server" ErrorMessage="Please Enter valid Email Address" Display="None" ControlToValidate="txtTo" SetFocusOnError="true" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                                        
      <asp:ValidatorCalloutExtender ID="vceTo1" runat="server" Enabled="True" TargetControlID="revTo"></asp:ValidatorCalloutExtender>
                                        
      <asp:RequiredFieldValidator ID="rfvFrom" runat="server" ErrorMessage="Please enter From Address" Display="None" ControlToValidate="txtFrom" SetFocusOnError="true"></asp:RequiredFieldValidator>
                                        
      <asp:ValidatorCalloutExtender ID="vceFrom" runat="server" Enabled="True" TargetControlID="rfvFrom"></asp:ValidatorCalloutExtender>
                                        
      <asp:RegularExpressionValidator ID="revFrom" runat="server" ErrorMessage="Please Enter valid Email Address" Display="None" ControlToValidate="txtFrom" SetFocusOnError="true" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ></asp:RegularExpressionValidator>
                                        
      <asp:ValidatorCalloutExtender ID="vceFrom1" runat="server" Enabled="True" TargetControlID="revFrom"></asp:ValidatorCalloutExtender>
                                        
       <asp:RequiredFieldValidator ID="rfvSubject" runat="server" ErrorMessage="Please enter Subject" Display="None" ControlToValidate="txtSubject" SetFocusOnError="true"></asp:RequiredFieldValidator>                                        
                                        
       <asp:ValidatorCalloutExtender ID="vceSubject" runat="server" Enabled="True" TargetControlID="rfvSubject"></asp:ValidatorCalloutExtender>
                                        
       <asp:RequiredFieldValidator ID="rfvMessage" runat="server" ErrorMessage="Please enter To Message" Display="None" ControlToValidate="txtMessage" SetFocusOnError="true"></asp:RequiredFieldValidator>
                                        
       <asp:ValidatorCalloutExtender ID="vceMessage" runat="server" Enabled="True" TargetControlID="rfvMessage"></asp:ValidatorCalloutExtender>

my code is :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="changepassword.aspx.cs" Inherits="changepassword" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td style="background-color: Gray " colspan="2" align = "center">
Create New User</td>
</tr>
<tr>
<td style="width: 155px; height: 26px;" >
First Name</td>
<td style="width: 246px; height: 26px;">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>&nbsp;
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="First Name is Required" ToolTip="First Name is Required"> *</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 155px; height: 26px">
Last Name</td>
<td style="width: 246px; height: 26px">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Last Name is Required" ControlToValidate="TextBox2" ToolTip="Last Name is Required">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 155px">
User Name</td>
<td style="width: 246px">
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBox5"
ErrorMessage="User Name is required" ToolTip="User Name is required">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 155px">
Password</td>
<td style="width: 246px">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Password is Required" ControlToValidate="TextBox3" ToolTip="Password is Required">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 155px; height: 21px">
Confirm Password</td>
<td style="width: 246px; height: 21px">
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Re-Type Password" ControlToCompare="TextBox3" ControlToValidate="TextBox4" ToolTip="Re-Type Password">*</asp:CompareValidator></td>
</tr>
<tr>
<td style="width: 155px; height: 21px">
</td>
<td style="width: 246px; height: 21px">
</td>
</tr>
<tr>
<td style="width: 155px; height: 21px">
</td>
<td style="width: 246px; height: 21px">
<asp:Button ID="Button1" runat="server" Style="left: 135px; position: relative; top: 8px"
Text="Create User" OnClick="Button1_Click" /><br />
</td>
</tr>
</table>

</div>
</form>
</body>
</html>

what is ValidatorCalloutExtender?

It is a Ajax Extender for Validators.

for your code i think this code will sutes

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Stored Procedures</title>
    <link href="Styles.css" type="text/css" rel="Stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <table class="table_all">
            <tr>
                <td>
                    <table class="table_all">
                        <tr>
                            <td class="hd_align_left">
                                <img alt="" src="Images/effoneicon.gif" />
                            </td>
                            <td class="hd_align_center">
                                <asp:Label runat="server" ID="heading">Login Record Using Stored Procedures</asp:Label>
                            </td>
                            <td class="hd_align_right">
                                <table class="table_all">
                                    <tr>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Button ID="btnrecord" runat="server" CssClass="button" Text="Records List" CausesValidation="false" 
                                                onclick="btnrecord_Click" UseSubmitBehavior="False" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table class="table_all">
                        <tr>
                            <td>
                                <asp:UpdatePanel ID="upan" runat="server">
                                    <ContentTemplate>
                                        <table class="table_all">
                                            <tr>
                                                <td>
                                                    <fieldset class="table_list">
                                                        <legend class="page_heading">Login
                                                        </legend>
                                                        <table class="table_all">
                                                            <tr>
                                                                <td colspan="2">                                                                
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <th>
                                                                    ID:<span style="color:Red" runat="server">*</span>
                                                                </th>
                                                                <td>
                                                                    <asp:TextBox runat="server" ID="txtid" CssClass="dropdownlist_large" MaxLength="50" ></asp:TextBox>                                                                          
                                                                </td>                                                                
                                                            </tr>
                                                            <tr>
                                                                <th>
                                                                    Password:<span style="color:Red" runat="server">*</span>
                                                                </th>
                                                                <td>
                                                                    <asp:TextBox runat="server" ID="txtpassword" CssClass="dropdownlist_large" MaxLength="50" TextMode="Password" ValidationGroup="pass"></asp:TextBox>
                                                                    <asp:PasswordStrength ID="PS" runat="server"
                                                                         TargetControlID="txtpassword"
                                                                          DisplayPosition="RightSide" CalculationWeightings="25;25;15;35" 
                                                                        MinimumSymbolCharacters="1" MinimumUpperCaseCharacters="1" 
                                                                        PreferredPasswordLength="10" RequiresUpperAndLowerCaseCharacters="True" 
                                                                        TextStrengthDescriptions="Poor; Weak; Good; Strong; Excellent" 
                                                                        HelpStatusLabelID="Lable1" StrengthIndicatorType="BarIndicator" 
                                                                        HelpHandlePosition="AboveLeft" BarBorderCssClass="barIndicatorBorder" 
                                                                        StrengthStyles="barIndicator_poor; barIndicator_weak; barIndicator_good; barIndicator_strong; barIndicator_excellent;">
                                                                    </asp:PasswordStrength>                                                                       
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <th>
                                                                    Confirm Password:<span runat="server" style="color:Red">*</span>
                                                                </th>
                                                                <td>
                                                                    <asp:TextBox runat="server" ID="txtconpassword" CssClass="dropdownlist_large" MaxLength="50" TextMode="Password" ValidationGroup="pass"></asp:TextBox>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <th>
                                                                    Email Id:<span runat="server" style="color:Red">*</span>
                                                                </th>
                                                                <td>
                                                                    <asp:TextBox runat="server" ID="txtemail" CssClass="dropdownlist_large" MaxLength="50"></asp:TextBox>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td class="hd_align_left">
                                                                    <asp:Button ID="btnsubmit" runat="server" CssClass="button" CausesValidation="true" Text="Submit Record" onclick="btnsubmit_Click" ToolTip="submit" />
                                                                </td>
                                                                <td class="hd_align_left">
                                                                    <asp:Button ID="btnReset" runat="server" CssClass="button" CausesValidation="False" Text="Reset" OnClick="btnReset_Click" />
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </fieldset>
                                                </td>
                                            </tr>
                                        </table>  
                                        
                                        <asp:RequiredFieldValidator ID="rfvid" runat="server" ErrorMessage="Please Enter Numerical Id" ControlToValidate="txtid" Display="None" ></asp:RequiredFieldValidator>
                                        
                                        <asp:ValidatorCalloutExtender ID="vceid" runat="server" Enabled="True" TargetControlID="rfvid">
                                        </asp:ValidatorCalloutExtender>
                                        
                                        <asp:CompareValidator id="CompareValidator1" runat="server" ErrorMessage="Passwords Do Not Match"  Display="None"
                                                 ControlToValidate="txtconpassword" ControlToCompare="txtpassword"></asp:CompareValidator>
                                        
                                        <asp:ValidatorCalloutExtender ID="vcCompareValidator" runat="server" 
                                            Enabled="True" TargetControlID="CompareValidator1">
                                        </asp:ValidatorCalloutExtender>
                                        
                                        <asp:RegularExpressionValidator ID="revemail" runat="server" ErrorMessage="Enter Correct Email Id" ControlToValidate="txtemail" Display="None" 
                                            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                                        <asp:ValidatorCalloutExtender ID="vceemail" runat="server" Enabled="True" 
                                            TargetControlID="revemail">
                                        </asp:ValidatorCalloutExtender>
                                    </ContentTemplate>
                                </asp:UpdatePanel> 
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <table class="table_all">
            <tr>
                <td>
                    <table class="table_footer">
                        <tr>
                            <td>
                                <asp:Label ID="Label2" runat="server">&copy 2011 Umamahesh Software,&reg Inc. All Rights Reserved.</asp:Label>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        
    </div>
    </form>
</body>
</html>

Copy this code and understand the design and validators logic

I am not able to use this code. It is giving lots of errors.

Your Code Modified and check this one .Also always design like this way other-wise to understand your code takes some time.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <table>
                <tr>
                    <th style="background-color: Gray " colspan="2" align = "center">
                    Create New User</th>
                </tr>
                <tr>
                    <th style="width: 155px; height: 26px;" >
                    First Name<span runat="server" style="color:Red">*</span>
                    </th>
                    <td style="width: 246px; height: 26px;">
                    <asp:TextBox ID="TextBox1" runat="server" MaxLength="50"></asp:TextBox>
                    </td>
                    <td  style="width: 246px; height: 26px;">
                    <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="TextBox1"
                         ErrorMessage="First Name is Required" ToolTip="FirstName" SetFocusOnError="true" >
                         </asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <th style="width: 155px; height: 26px">
                    Last Name
                    <span runat="server" style="color:Red">*</span>
                    </th>
                    <td style="width: 246px; height: 26px">
                    <asp:TextBox ID="TextBox2" runat="server" MaxLength="50"></asp:TextBox>
                    </td><td>
                    <asp:RequiredFieldValidator ID="rfvLastName" runat="server" ErrorMessage="Last Name is Required" ControlToValidate="TextBox2" ToolTip="LastName" SetFocusOnError="true"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <th style="width: 155px">
                    User Name<span runat="server" style="color:Red">*</span>
                    </th>
                    <td style="width: 246px">
                    <asp:TextBox ID="TextBox5" runat="server" MaxLength="50"></asp:TextBox>
                    </td><td>
                    <asp:RequiredFieldValidator ID="rfvUserName" runat="server" ControlToValidate="TextBox5"
                    ErrorMessage="User Name is required" ToolTip="UserName"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <th style="width: 155px">
                    Password<span  runat="server" style="color:Red">*</span>
                    </th>
                    <td style="width: 246px">
                    <asp:TextBox ID="TextBox3" runat="server" TextMode="Password" MaxLength="10"></asp:TextBox>
                    </td><td>
                    <asp:RequiredFieldValidator ID="rfvPassword" runat="server" ErrorMessage="Password is Required" ControlToValidate="TextBox3" ToolTip="Password"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td style="width: 155px; height: 21px">
                    Confirm Password<span id="Span1" runat="server" style="color:Red">*</span>
                    </td>
                    <td style="width: 246px; height: 21px">
                    <asp:TextBox ID="TextBox4" TextMode="Password" runat="server" MaxLength="10"></asp:TextBox>
                    </td><td>
                    <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Re-Type Password" ControlToCompare="TextBox3" ControlToValidate="TextBox4" ToolTip="Re-Type Password">
                    </asp:CompareValidator>
                    </td>
                </tr>
                <tr>
                    <td style="width: 155px; height: 21px">
                    </td>
                    <td style="width: 246px; height: 21px">
                    </td>
                </tr>
                <tr>
                    <td style="width: 155px; height: 21px">
                    </td>
                    <td style="width: 246px; height: 21px">
                    <asp:Button ID="Button1" runat="server" Style="left: 135px; position: relative; top: 8px"
                    Text="Create User" OnClick="Button1_Click"/><br />
                    </td>
                </tr>
            </table>

        </div>
    </form>
</body>
</html>

if you want ajax validators, agian i will do it for u

Thanks but tell me what i have to write on button click?

what did need tell me exactly then only i will help you and also show the code you have written for the "Button_Click" event

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.