LayoutTemplate Error In Asp.Net - asp.net

i have a login and register form when i click on register form link button then it shows me error like this i.e PARSE ERROR
when i click on register link it shows me error
Parser Error Message: Type 'System.Web.UI.WebControls.CreateUserWizard' does
not have a public property named 'LayoutTemplate'.
Source Error:
Line 6: <asp:Content ID="BodyContent" runat="server"
ContentPlaceHolderID="MainContent">
Line 7: <asp:CreateUserWizard ID="RegisterUser" runat="server"
EnableViewState="false" OnCreatedUser="RegisterUser_CreatedUser">
Line 8: <LayoutTemplate>
Line 9: <asp:PlaceHolder ID="wizardStepPlaceholder"
runat="server"></asp:PlaceHolder>
Line 10: <asp:PlaceHolder ID="navigationPlaceholder"
runat="server"></asp:PlaceHolder>
CODE IN REGISTER.ASPX IN HTML
<asp:CreateUserWizard ID="RegisterUser" runat="server" EnableViewState="false"
OnCreatedUser="RegisterUser_CreatedUser">
<LayoutTemplate>
<asp:PlaceHolder ID="wizardStepPlaceholder" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="navigationPlaceholder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<WizardSteps>
<asp:CreateUserWizardStep ID="RegisterUserWizardStep" runat="server">
<ContentTemplate>
<h2>
Create a New Account
</h2>
<p>
Use the form below to create a new account.
</p>
<p>
Passwords are required to be a minimum of <%=
Membership.MinRequiredPasswordLength %> characters in length.
</p>
<span class="failureNotification">
<asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="RegisterUserValidationSummary"
runat="server" CssClass="failureNotification"
ValidationGroup="RegisterUserValidationGroup"/>
<div class="accountInfo">
<fieldset class="register">
<legend>Account Information</legend>
<p>
<asp:Label ID="UserNameLabel" runat="server"
AssociatedControlID="UserName">User Name:</asp:Label>
<asp:TextBox ID="UserName" runat="server"
CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired"
runat="server" ControlToValidate="UserName"
CssClass="failureNotification" ErrorMessage="User
Name is required." ToolTip="User Name is required."
ValidationGroup="RegisterUserValidationGroup">*
</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="EmailLabel" runat="server"
AssociatedControlID="Email">E-mail:</asp:Label>
<asp:TextBox ID="Email" runat="server"
CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequired"
runat="server" ControlToValidate="Email"
CssClass="failureNotification" ErrorMessage="E-mail
is required." ToolTip="E-mail is required."
ValidationGroup="RegisterUserValidationGroup">*
</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="PasswordLabel" runat="server"
AssociatedControlID="Password">Password:</asp:Label>
<asp:TextBox ID="Password" runat="server"
CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired"
runat="server" ControlToValidate="Password"
CssClass="failureNotification" ErrorMessage="Password
is required." ToolTip="Password is required."
ValidationGroup="RegisterUserValidationGroup">*
</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="ConfirmPasswordLabel" runat="server"
AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
<asp:TextBox ID="ConfirmPassword" runat="server"
CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator
ControlToValidate="ConfirmPassword" CssClass="failureNotification
Display="Dynamic"
ErrorMessage="Confirm Password is required."
ID="ConfirmPasswordRequired" runat="server"
ToolTip="Confirm Password is required."
ValidationGroup="RegisterUserValidationGroup">*
</asp:RequiredFieldValidator>
<asp:CompareValidator ID="PasswordCompare" runat="server"
ControlToCompare="Password" ControlToValidate="ConfirmPassword"
CssClass="failureNotification" Display="Dynamic"
ErrorMessage="The Password and Confirmation Password must match."
ValidationGroup="RegisterUserValidationGroup">*
</asp:CompareValidator>
</p>
</fieldset>
<p class="submitButton">
<asp:Button ID="CreateUserButton" runat="server"
CommandName="MoveNext" Text="Create User"
ValidationGroup="RegisterUserValidationGroup"/>
</p>
</div>
</ContentTemplate>
<CustomNavigationTemplate>
</CustomNavigationTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
HOW I REMOVE THIS ERROR FROM FORM ANY HELP?

LayoutTemplate is available from version 4.0 onwards. If you comment out the code corresponding lines from your code, you should be able to successfully compile it.
EDIT: I noticed that your code does not contain the declaration for Security Question and Answer fields, which is causing the exception to be thrown. You can add in the required fields as shown in the code sample on MSDN for version 3.5.

Related

ASP WebForms AutoCompleteExtender in GridView not firing

I have this webform with 3 AutoCompleteExtenders using the AjaxControlToolkit. The first one deals with customers from a database and that works very well. I have place 2 others in a gridview, AutoCompleteExtenders 2 and 3 to fetch items. For some reason, these do not work and a breakpoint in Items.asmx does not reach when running the code. I have setup these 2 extenders same as the customer one.
What am I doing wrong? I have searched articles online on use in gridviews but am unable to find the issue.
I have
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
in the masterpage.
Code in webform:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PipemanWebPortal.Views.PurchaseOrders.Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Add Purchase Order</h2>
<script type="text/javascript">
$(document).ready(function () {
window.setTimeout(function () {
$(".alert").fadeTo(1500, 0).slideUp(500, function () {
$(this).remove();
});
}, 3000);
});
// On Page Load
$(function () {
SetDatePicker();
});
// On UpdatePanel Refresh
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
prm.add_endRequest(function (sender, e) {
if (sender._postBackSettings.panelsToUpdate != null) {
SetDatePicker();
$(".datepicker-orient-bottom").hide();
}
});
};
function SetDatePicker() {
$('#datetimepicker').datepicker
({
format: 'dd.MM.yyyy',
inline: true,
todayHighlight: true,
autoclose: true
});
}
</script>
<div runat="server" visible="false" id="AlertDanger" class="alert alert-danger">
×
<strong>You must choose a date</strong>
</div>
<div runat="server" visible="false" id="AlertSuccess" class="alert alert-success">
×
<strong>Purchase requisition saved successfully</strong>
</div>
<asp:Panel ID="PODetails" runat="server">
<div>
<asp:UpdatePanel ID="UpdatePanelPO" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" BackColor="#E6E6E6">
<fieldset class="form-horizontal">
<div class="row">
<div class="form-group col-sm-6">
<asp:Label runat="server" CssClass="col-sm-6 control-label">Required Date</asp:Label>
<div class="col-sm-6">
<div class="input-group date" id="datetimepicker">
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
<asp:TextBox ID="txtRequiredDate" runat="server" CssClass="form-control"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtRequiredDate" Display="Dynamic"
CssClass="text-danger" ErrorMessage="The Required Date field is required." />
</div>
</div>
</div>
<div class="form-group col-sm-6">
<asp:Label runat="server" CssClass="col-sm-6 control-label">No.</asp:Label>
<div class="col-sm-6">
<asp:Label ID="lblDocNum" runat="server" CssClass="form-control"></asp:Label>
</div>
</div>
</div>
</fieldset>
<fieldset class="form-horizontal">
<div class="row">
<div class="form-group col-sm-6">
<asp:Label runat="server" CssClass="col-sm-6 control-label" class="">Cust. PO No.</asp:Label>
<div class="col-sm-6">
<div class="input-group">
<asp:TextBox ID="txtPurchaseOrderNo" runat="server" CssClass="form-control"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtPurchaseOrderNo" Display="Dynamic"
CssClass="text-danger" ErrorMessage="The Cust. Purchase Order No field is required." />
</div>
</div>
</div>
<div class="form-group col-sm-6">
<asp:Label runat="server" CssClass="col-sm-6 control-label">Contact</asp:Label>
<div class="col-sm-6">
<div class="input-group">
<asp:TextBox ID="txtContact" runat="server" CssClass="form-control"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtContact" Display="Dynamic"
CssClass="text-danger" ErrorMessage="The Contact field is required." />
</div>
</div>
</div>
</div>
</fieldset>
<fieldset class="form-horizontal">
<div class="row">
<div class="form-group col-sm-3">
<asp:Label runat="server" CssClass="col-sm-12 control-label" class="">Customer Name</asp:Label>
</div>
<div class="form-group col-sm-9">
<asp:TextBox ID="txtCustomer" runat="server" CssClass="form-control"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="AutoCompleteExtender1"
runat="server"
TargetControlID="txtCustomer"
ServicePath="../../Web_Service/Customers.asmx"
ServiceMethod="GetCustomers"
MinimumPrefixLength="2"
EnableCaching="true"
CompletionSetCount="10"
CompletionInterval="10"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtCustomer" Display="Dynamic"
CssClass="text-danger" ErrorMessage="The Customer field is required." />
</div>
</div>
</div>
</fieldset>
</asp:Panel>
<asp:GridView ID="pOGridView"
runat="server"
AutoGenerateColumns="False"
AllowPaging="True"
AllowSorting="True"
ShowFooter="True"
OnRowEditing="pOGridView_RowEditing"
OnRowUpdating="pOGridView_RowUpdating"
OnPageIndexChanging="pOGridView_PageIndexChanging"
OnRowCancelingEdit="pOGridView_RowCancelingEdit"
PagerStyle-CssClass="bs-pagination"
ShowHeaderWhenEmpty="True"
EmptyDataText="No Records Found"
CssClass="table table-striped table-bordered table-hover table-condensed">
<Columns>
<asp:TemplateField ItemStyle-Width="30px" HeaderText="#">
<ItemTemplate>
<asp:Label ID="lblLineNum" Text='<%# Container.DataItemIndex + 1 %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="120px" HeaderText="Item">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server"
Text='<%# Bind("Item")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtItem" runat="server" Width="300px" Text='<%# Bind("Item")%>'></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="AutoCompleteExtender2"
runat="server"
TargetControlID="txtItem"
ServicePath="../../Web_Service/Items.asmx"
ServiceMethod="GetItems"
MinimumPrefixLength="2"
EnableCaching="true"
CompletionSetCount="10"
CompletionInterval="10"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtItem" Display="Dynamic" ValidationGroup="Edit"
CssClass="text-danger" ErrorMessage="The Item field is required." />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtItem" runat="server" Width="300px"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="AutoCompleteExtender3"
runat="server"
TargetControlID="txtItem"
ServicePath="../../Web_Service/Items.asmx"
ServiceMethod="GetItems"
MinimumPrefixLength="2"
EnableCaching="true"
CompletionSetCount="10"
CompletionInterval="10"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtItem" Display="Dynamic" ValidationGroup="Insert"
CssClass="text-danger" InitialValue="-1" ErrorMessage="The Item field is required." />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="60px" HeaderText="Qty.">
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server"
Text='<%# Bind("Quantity")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" Width="100px"
Text='<%# Bind("Quantity")%>'></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtQuantity" Display="Dynamic" ValidationGroup="Edit"
CssClass="text-danger" ErrorMessage="The Quantity field is required." />
<asp:RegularExpressionValidator ControlToValidate="txtQuantity" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only integers allowed." ValidationExpression="^(0|[1-9]\d*)$"
ValidationGroup="Edit"></asp:RegularExpressionValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtQuantity" runat="server" Width="100px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtQuantity" Display="Dynamic" ValidationGroup="Insert"
CssClass="text-danger" ErrorMessage="The Quantity field is required." />
<asp:RegularExpressionValidator ControlToValidate="txtQuantity" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only integers allowed." ValidationExpression="^(0|[1-9]\d*)$"
ValidationGroup="Insert"></asp:RegularExpressionValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="80px" HeaderText="Unit Price">
<ItemTemplate>
<asp:Label ID="lblUnitPrice" runat="server"
Text='<%# Bind("UnitPrice")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUnitPrice" runat="server" Width="100px"
Text='<%# Bind("UnitPrice")%>'></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtUnitPrice" Display="Dynamic" ValidationGroup="Edit"
CssClass="text-danger" ErrorMessage="The Unit Price is required." />
<asp:RegularExpressionValidator ControlToValidate="txtUnitPrice" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only numbers allowed." ValidationExpression="^[0-9]{0,6}(\.[0-9]{1,2})?$"
ValidationGroup="Edit"></asp:RegularExpressionValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtUnitPrice" runat="server" Width="100px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtUnitPrice" Display="Dynamic" ValidationGroup="Insert"
CssClass="text-danger" ErrorMessage="The Unit Price is required." />
<asp:RegularExpressionValidator ControlToValidate="txtUnitPrice" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only numbers allowed." ValidationExpression="^[0-9]{0,6}(\.[0-9]{1,2})?$"
ValidationGroup="Insert"></asp:RegularExpressionValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="80px" HeaderText="Order Price">
<ItemTemplate>
<asp:Label ID="lblOrderPrice" runat="server"
Text='<%# Bind("OrderPrice")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtOrderPrice" runat="server" Width="100px"
Text='<%# Bind("OrderPrice")%>'></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtOrderPrice" Display="Dynamic" ValidationGroup="Edit"
CssClass="text-danger" ErrorMessage="The Order Price is required." />
<asp:RegularExpressionValidator ControlToValidate="txtOrderPrice" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only numbers allowed." ValidationExpression="^[0-9]{0,6}(\.[0-9]{1,2})?$"
ValidationGroup="Edit"></asp:RegularExpressionValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtOrderPrice" runat="server" Width="100px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtUnitPrice" Display="Dynamic" ValidationGroup="Insert"
CssClass="text-danger" ErrorMessage="The Order Price is required." />
<asp:RegularExpressionValidator ControlToValidate="txtOrderPrice" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only numbers allowed." ValidationExpression="^[0-9]{0,6}(\.[0-9]{1,2})?$"
ValidationGroup="Insert"></asp:RegularExpressionValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ValidationGroup="Edit" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkRemove" runat="server"
CommandArgument='<%# Bind("LineNum")%>'
OnClientClick="return confirm('Are you sure you want to delete this row?')"
Text="Delete" OnClick="DeleteRowPurchaseOrder"></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="btnAdd" runat="server" Text="Add" ValidationGroup="Insert" CssClass="btn btn-primary btn-sm"
OnClick="AddRowPurchaseOrder" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div class="form-group">
<div class="row">
<div class="col-sm-3">
<asp:Button runat="server" ID="InsertButton" OnClick="Insert" Text="Insert" CssClass="btn btn-block btn-primary" />
</div>
<div class="col-sm-3">
<asp:Button runat="server" ID="CancelButton" OnClick="Cancel" Text="Cancel" CausesValidation="false" CssClass="btn btn-block btn-default" />
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Panel>
</asp:Content>
Looks like the other two AutoCompleteExtender are on two different <asp:Panel>, try put on same Panel,
<asp:Panel ID="Panel1" runat="server" BackColor="#E6E6E6">. that's probably the reason why the first one is working, and other two are not.

How to stop redirecting to next page when validation fails?

I have put validation on controls like TextBox on a Form in ASP.NET. When validation fails it is still redirecting to next page. How do I resolve this?
<div class="inp-cont forget-success-hide">
<label for="inputFirstName">Name <span class="text-error"
style="Color:Red">*</span></label>
<asp:TextBox runat="server" class="signininput" ID="txtname" placeholder="Enter Your
Name"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ForeColor="Red"
ValidationGroup="rg" ErrorMessage="Please enter Your Name"
ControlToValidate="txtname"></asp:RequiredFieldValidator>
<br/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3"
runat="server" ControlToValidate="txtname" ErrorMessage="Only
alphabets are allowed" ForeColor="Red"
ValidationExpression="[a-zA-Z]+" > </asp:RegularExpressionValidator>
</div>
<div class="inp-cont forget-success-hide">
<label for="inputFirstName">Email <span class="text-error"
style="Color:Red">*</span></label>
<asp:TextBox runat="server" class="signininput" ID="txtemail" placeholder="Enter Your Email
Id"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ForeColor="Red"
ValidationGroup="rg" ErrorMessage="Please enter email id"
ControlToValidate="txtemail"></asp:RequiredFieldValidator>
<br />
<asp:RegularExpressionValidator ID="rv" runat="server"
ControlToValidate="txtemail" ForeColor="Red" ValidationGroup="rg"
ErrorMessage="Enter vaild email id"
ValidationExpression="\w+([-+.]\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
<asp:Label ID="lblemail" ForeColor="Red" runat="server" Visible="false"></asp:Label>
</div>
<div class="inp-cont forget-success-hide">
<label for="inputLastName">Gender <span class="text-error"
style="Color:Red">*</span></label>
<asp:DropDownList ID="ddlGender" runat="server" class="signininput" Width="100%">
<asp:ListItem Text="Select Gender" Value="0"></asp:ListItem>
<asp:ListItem Text="Male" Value="1"></asp:ListItem>
<asp:ListItem Text="Female" Value="2"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ForeColor="Red"
ValidationGroup="rg" ErrorMessage="Please select gender"
InitialValue="0"
ControlToValidate="ddlGender"></asp:RequiredFieldValidator>
</div>
<div class="inp-cont forget-success-hide">
<label for="inputEMail">Password <span class="text-error"
style="Color:Red">*</span></label>
<asp:TextBox runat="server" class="signininput" ID="txtpwd" MaxLength="20" TextMode="Password"
placeholder="Enter Your Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ForeColor="Red"
ValidationGroup="rg" ErrorMessage="Please enter password"
ControlToValidate="txtpwd"></asp:RequiredFieldValidator>
</div>
<div class="inp-cont forget-success-hide">
<label for="inputEMail">Confirm Password <span class="text-error"
style="Color:Red">*</span></label>
<asp:TextBox runat="server" class="signininput" ID="txtcpwd" MaxLength="20" TextMode="Password"
placeholder="Enter Confirm Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ForeColor="Red"
ValidationGroup="rg" ErrorMessage="Please enter confirm password"
ControlToValidate="txtcpwd"></asp:RequiredFieldValidator>
<br />
<asp:CompareValidator ID="cmp" runat="server" ForeColor="Red" ValidationGroup="rg"
ErrorMessage="Password does not match" ControlToCompare="txtpwd"
ControlToValidate="txtcpwd" Type="String"
Operator="Equal"></asp:CompareValidator>
<asp:Label ID="lblpwd" ForeColor="Red" runat="server" Visible="false"></asp:Label>
</div>
<div class="inp-cont forget-success-hide">
<label for="inputMob">Mobile No <span class="text-error" style="Color:Red">*</span></label>
<asp:TextBox runat="server" MaxLength="10" class="signininput"
onkeypress="inputNumberOnly(event)" ID="txtmobno" placeholder="Enter
Your Mobile"></asp:TextBox>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="txtmobno"
ValidationGroup="rg" ForeColor="Red" ErrorMessage="Enter a valid
phone number"
ValidationExpression="^[7-9][0-9](\s){0,1}(\-){0,1}(\s){0,1}[0-9]{1}[0-9]{7}$"></asp:RegularExpressionValidator><br
/>--%>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="txtmobno"
ValidationGroup="rg" ForeColor="Red" ErrorMessage="Enter a valid
mobile number"
ValidationExpression="^[789]\d{9}$"></asp:RegularExpressionValidator>
<br
/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ForeColor="Red"
ValidationGroup="rg" ErrorMessage="Please enter mobile number"
ControlToValidate="txtmobno"></asp:RequiredFieldValidator>
</div>
properly use validation group and in button control add validation group and check that validation group name should be same in button control and other controls also where we have used asp.net validation control

how to prevent redirecting on register user in asp.net

hi i am using createuserwizard server control but facing little bit problem when ever i am registering user through this control it's automatically navigate and login to created user i don't want to that that on user creation go to automatically how can it would be possible any idea.
here is aspx code:-
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnCreatedUser="CreateUserWizard1_CreatedUser" OnNextButtonClick="CreateUserWizard1_NextButtonClick">
<WizardSteps>
<asp:WizardStep ID="CreateUserWizardStep0" runat="server">
<table cellpadding="1" cellspacing="0" style="border-collapse: collapse;" class="MarginStyle">
<tr>
<td>
<h4 class="HeadingThemeColor align I18N">TitleAddTeacher</h4>
</td>
</tr>
<tr>
<td>
<table cellpadding="10">
<tr>
<td>
<asp:Label ID="LblOrganization" CssClass="lblStyle I18N" runat="server">form.data.Organizations</asp:Label>
<br />
<br />
<asp:DropDownList ID="DplOrganization" runat="server">
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator ID="DplOrganizationRequiredFieldValidator" runat="server"
ControlToValidate="DplOrganization" Display="Dynamic" ErrorMessage="Organization Name must Selected."
ToolTip="Organization Name must Selected." ValidationGroup="AddInstitution"><span class="err I18N">error.messages.Organization Name must Selected</span></asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="LblInstitutes" CssClass="lblStyle I18N" runat="server">form.data.Institutes</asp:Label>
<br />
<br />
<asp:DropDownList ID="DplInstitutes" runat="server">
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator ID="DplInstitutesRequiredFieldValidator" runat="server"
ControlToValidate="DplInstitutes" Display="Dynamic" ErrorMessage="Institute Name must Selected."
ToolTip="Institute Name must Selected." ValidationGroup="AddBranch"><span class="err I18N">error.messages.Institute Name must Selected</span></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblBranches" CssClass="lblStyle I18N" runat="server">form.data.Branches</asp:Label>
<br />
<br />
<asp:DropDownList ID="DplBranch" runat="server">
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator ID="DplBranchRequiredFieldValidator" runat="server"
ControlToValidate="DplBranch" Display="Dynamic" ErrorMessage="Branch Name must Selected."
ToolTip="Branch Name must Selected." ValidationGroup="AddInstitution"><span class="err I18N">error.messages.Branch Name must Selected</span></asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label4" CssClass="lblStyle I18N" runat="server">form.data.Marital Status</asp:Label>
<br />
<br />
<asp:TextBox ID="TxtMaritalStatus" runat="server" CssClass="txt" placeholder="Marital Status" TextMode="SingleLine"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator16" runat="server"
ControlToValidate="TxtMaritalStatus" Display="Dynamic" ErrorMessage="Marital Status is required."
ToolTip="Marital Status is required." ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Marital Status is required</span></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" CssClass="lblStyle I18N" runat="server">form.data.Company</asp:Label>
<br />
<br />
<asp:TextBox ID="TxtCompany" runat="server" CssClass="txt" placeholder="Company" TextMode="SingleLine"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator17" runat="server"
ControlToValidate="TxtCompany" ErrorMessage="Company is required."
ToolTip="Company is required." Display="Dynamic" ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Company is required</span></asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label6" CssClass="lblStyle I18N" runat="server">form.data.Occupation</asp:Label>
<br />
<br />
<asp:TextBox ID="TxtOccupation" runat="server" CssClass="txt" placeholder="Teacher Occupation" TextMode="SingleLine"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator19" runat="server"
ControlToValidate="TxtOccupation" ErrorMessage="Teacher Occupation is required."
ToolTip="Teacher Occupation is required." Display="Dynamic" ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Occupation is required</span></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" CssClass="lblStyle I18N" runat="server">form.data.Passport Numer</asp:Label>
<br />
<br />
<asp:TextBox ID="TxtPassportNumer" runat="server" CssClass="txt" placeholder="Teacher Postal Code" TextMode="SingleLine"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator20" runat="server"
ControlToValidate="TxtPassportNumer" ErrorMessage="Teacher Passport Numer is required."
ToolTip="Teacher Passport Numer is required." Display="Dynamic" ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Passport Numer is required</span></asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label8" CssClass="lblStyle I18N" runat="server">form.data.Upload Image</asp:Label>
<br />
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:WizardStep>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse: collapse;" class="MarginStyle">
<tr>
<td>
<h4 class="HeadingThemeColor align I18N">TitleAddTeacher</h4>
</td>
</tr>
<tr>
<td>
<table cellpadding="10">
<tr>
<td>
<asp:Label ID="LblUserName" CssClass="lblStyle I18N" runat="server">form.data.UserName</asp:Label>
<br />
<br />
<asp:TextBox runat="server" ID="UserName" CssClass="txt" placeholder="User Name" TextMode="SingleLine"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" Display="Dynamic" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="AddTeacher"><span class="err I18N">error.messages.User Name is required</span></asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="LblPassword" CssClass="lblStyle I18N" runat="server">form.data.Password</asp:Label>
<br />
<br />
<asp:TextBox runat="server" ID="Password" TextMode="Password" CssClass="txt" placeholder="Password"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"
ControlToValidate="Password" Display="Dynamic" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Password is required</span></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblConfirmPassword" CssClass="lblStyle I18N" runat="server">form.data.Confirm Password</asp:Label>
<br />
<br />
<asp:TextBox runat="server" ID="ConfirmPassword" CssClass="txt" placeholder="Confirm Password" TextMode="Password"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server"
ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="Confirm Password is required."
ToolTip="User Name is required." ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Confirm Password is required</span></asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="LblEmail" CssClass="lblStyle I18N" runat="server">form.data.Email</asp:Label>
<br />
<br />
<asp:TextBox runat="server" ID="Email" TextMode="SingleLine" CssClass="txt" placeholder="Email"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator18" runat="server"
ControlToValidate="Email" Display="Dynamic" ErrorMessage="Email is required."
ToolTip="Email is required." ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Email is required</span></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblQuestion" CssClass="lblStyle I18N" runat="server">form.data.Question</asp:Label>
<br />
<br />
<asp:TextBox runat="server" ID="Question" CssClass="txt" placeholder="Question" TextMode="SingleLine"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server"
ControlToValidate="Question" Display="Dynamic" ErrorMessage="Question is required."
ToolTip="Question is required." ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Question is required</span></asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="LblAnswer" CssClass="lblStyle I18N" runat="server">form.data.Answer</asp:Label>
<br />
<br />
<asp:TextBox runat="server" ID="Answer" TextMode="SingleLine" CssClass="txt" placeholder="Answer"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server"
ControlToValidate="Answer" Display="Dynamic" ErrorMessage="Answer is required."
ToolTip="Answer is required." ValidationGroup="AddTeacher"><span class="err I18N">error.messages.Answer is required</span></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:CompareValidator ID="PasswordCompare" runat="server"
ControlToValidate="ConfirmPassword" ControlToCompare="Password" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
ToolTip="The Password and Confirmation Password must match." ValidationGroup="AddTeacher"><span class="err I18N">error.messages.PasswordMsg</span></asp:CompareValidator>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
<NavigationButtonStyle CssClass="navigateButton" />
<HeaderStyle BackColor="White" BorderColor="#FFFBD6" BorderStyle="Solid" BorderWidth="2px"
Font-Bold="True" Font-Size="0.9em" ForeColor="#333333" HorizontalAlign="Center" />
<CreateUserButtonStyle CssClass="navigateButton" />
<ContinueButtonStyle CssClass="navigateButton" />
<SideBarStyle BackColor="White" Font-Size="0.9em" VerticalAlign="Top" />
<TitleTextStyle BackColor="White" Font-Bold="True" ForeColor="White" />
<SideBarButtonStyle CssClass="navigateButton" />
</asp:CreateUserWizard>
possibly two things:
You can try using the FinishDestinationPageUrl property of the CreateUserWizard control. Try setting to empty.
Another is you should handle the FinishButtonClick event.
This is fired when finish button is clicked. Basically implement your own logic over there. So, you can prevent default behavior.

Adding more controls to readymade ones

Hi I started new with asp.net
Started building up a website but here's where I got stuck,
Used the readymade theme which contains a register user control
Which has a textbox for accepting username n password.
I added 3 more controls by copy pasting the code for the username n password, particularly for the contact nos, address etc....
BUT THEN THE TEXTBOXES WHICH WERE ADDED BY ME AREN'T ACCESSIBLE IN THE ASPX.CS FILE!
I can access the readymade controls as: RegisterUser.UserName
But when I try to access RegisterUser.Address it is not available
CODE:
<asp:CreateUserWizard ID="RegisterUser" runat="server" EnableViewState="false" OnCreatedUser="RegisterUser_CreatedUser">
<FinishCompleteButtonStyle BorderStyle="None" />
<FinishPreviousButtonStyle BorderStyle="None" />
<LayoutTemplate>
<asp:PlaceHolder ID="wizardStepPlaceholder" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="navigationPlaceholder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<ContinueButtonStyle BorderStyle="None" />
<WizardSteps>
<asp:CreateUserWizardStep ID="RegisterUserWizardStep" runat="server">
<ContentTemplate>
<h2>
Create a New Account
</h2>
<p>
Use the form below to create a new account.
</p>
<p>
Passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length.
</p>
<span class="failureNotification">
<asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification"
ValidationGroup="RegisterUserValidationGroup"/>
<div class="accountInfo">
<fieldset class="register">
<legend>Account Information</legend>
<p>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
<asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
<asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
<asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
<asp:TextBox ID="ConfirmPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic"
ErrorMessage="Confirm Password is required." ID="ConfirmPasswordRequired" runat="server"
ToolTip="Confirm Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
<asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword"
CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
ValidationGroup="RegisterUserValidationGroup">*</asp:CompareValidator>
</p>
<p>
<asp:Label ID="AddressLabel" runat="server" AssociatedControlID="Address">Address:</asp:Label>
<asp:TextBox ID="Address" runat="server" CssClass="textEntry" ></asp:TextBox>
<asp:RequiredFieldValidator ID="AddressRequired" runat="server" ControlToValidate="Address"
CssClass="failureNotification" ErrorMessage="Address is required." ToolTip="Address is required."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="ContactLabel" runat="server" AssociatedControlID="Contact">Contact No:</asp:Label>
<asp:TextBox ID="Contact" runat="server" CssClass="textEntry" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Contact"
CssClass="failureNotification" ErrorMessage="Contact is missing." ToolTip="Contact is required."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Should contain 10-12 digits."></asp:CustomValidator>
</p>
<p>
<asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="SecurityQuestion">Security Question:</asp:Label>
<asp:TextBox ID="SecurityQuestion" runat="server" CssClass="textEntry" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="SecurityQuestion"
CssClass="failureNotification" ErrorMessage="Security Question Required" ToolTip="Security Question is crucial for your account recovery, incase you lose it!"
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="SecurityAnswer">Answer:</asp:Label>
<asp:TextBox ID="SecurityAnswer" runat="server" CssClass="textEntry" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="SecurityAnswer"
CssClass="failureNotification" ErrorMessage="An Answer is required to the question!" ToolTip="Answer pertaining to the question above."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
</fieldset>
<p class="submitButton">
<asp:Button ID="CreateUserButton" runat="server" CommandName="MoveNext" Text="Create User" EnableTheming=true
ValidationGroup="RegisterUserValidationGroup"/>
</p>
</div>
</ContentTemplate>
<CustomNavigationTemplate>
</CustomNavigationTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep runat="server"></asp:CompleteWizardStep>
</WizardSteps>
<StartNextButtonStyle BorderStyle="None" />
<StepNextButtonStyle BorderStyle="None" />
<StepPreviousButtonStyle BorderStyle="None" />
</asp:CreateUserWizard>
Am surprised!! plz help,
You can achieve this in few steps.
Create a new field Mobile in table aspnet_Users table.
Convert your createUserWizard to template.
I am removing much of the code for keeping it short and nice. Notice how Mobile filed is included in wizard.
Code:
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
CreateUserButtonText="Sign Up"
oncreateduser="CreateUserWizard1_CreatedUser" >
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" Title="CreateUser" runat="server">
<ContentTemplate>
<table border="0" style="background:gray" id="TABLE2">
<tr>
<td align="center" colspan="2">
Sign Up for Your New Account</td>
</tr>
<tr>
<td align="right" class="style4">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User
Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"> </asp:TextBox>
</td>
</tr>
Your Mobile No:
Enter Mobile No
In code behind add namespace System.Data.SqlClient ;
and below page_load event use this code
Code:
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
if (CreateUserWizard1.ActiveStep.Title == "CreateUser")
{
TextBox mobile = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Mob");
string connectionString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
string insertSql = "INSERT INTO aspnet_Users(Mobile) VALUES(#AddMob)";
using (SqlConnection myConnection = new SqlConnection(connectionString))
{
myConnection.Open();
SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
myCommand.Parameters.AddWithValue("#AddMob", mobile.Text);
myCommand.ExecuteNonQuery();
myConnection.Close();
}
}
}
Hope this helps...

ValidationSummary always showing asterisks

I have the following setup for a changepassword control:
<asp:ChangePassword ID="ChangePassword1" runat="server">
<ChangePasswordTemplate>
<h3>
Password Management</h3>
<asp:TextBox ID="CurrentPassword" runat="server" TextMode="Password" Style="display: none;"></asp:TextBox>
<div class="field">
<asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label>
<asp:TextBox ID="NewPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" Display="Dynamic"
ErrorMessage="New Password" ToolTip="New Password is required."
ValidationGroup="ChangePassword1" EnableClientScript="false"></asp:RequiredFieldValidator>
</div>
<div class="field">
<asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label>
<asp:TextBox ID="ConfirmNewPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword"
ErrorMessage="Confirm New Password" ToolTip="Confirm New Password is required." Display="Dynamic"
ValidationGroup="ChangePassword1" EnableClientScript="false"></asp:RequiredFieldValidator>
</div>
<div class="field">
<asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword"
ControlToValidate="ConfirmNewPassword" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry."
ValidationGroup="ChangePassword1"></asp:CompareValidator>
</div>
<asp:ValidationSummary ID="ChangeUserPasswordValidationSummary" runat="server" CssClass="failureNotification"
ValidationGroup="ChangePassword1"/>
<div class="action">
<asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword"
Text="Change Password" ValidationGroup="ChangePassword1" />
<asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" Width="120" />
</div>
</ChangePasswordTemplate>
</asp:ChangePassword>
When i click on the ChangePasswordPushButton the validation all works as expected other than the validationsummary shows 2 asterisks!
Anyone have any idea why
I found out what the problem was. Error message was being set in a Theme!
Grrr
Try adding the following code on all of your validators and the ValidationSummary:
EnableTheming="False"

Resources