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"
Related
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.
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
I have a very basic form in a .Net page, it has 6 fields each with a requiredfieldvalidator attached. Everything works fine and the form is stopped if even one field is blank. I was asked to add a section with 2 radio buttons (I set one option as checked to avoid any validation on the field), now the form submits no matter if the fields have information in them or not.
Subset of default.aspx
<form id="form1" runat="server">
<div style="margin-bottom:10px;">
<label for="txtAgencyName">Name of Agency</label>
<asp:TextBox ID="txtAgencyName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvAgencyName" runat="server" ErrorMessage="*Required" ControlToValidate="txtAgencyName" ValidationGroup="vg1" CssClass="rfvErrors"></asp:RequiredFieldValidator>
</div>
<div style="margin-bottom:10px;">
<label for="txtEmail">Email Address</label>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEmail" runat="server" ErrorMessage="*Required" ControlToValidate="txtEmail" ValidationGroup="vg1" CssClass="rfvErrors"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEmail" runat="server" ErrorMessage="Invalid Email Address" CssClass="revErrors" ValidationExpression="(^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*#([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$)" ValidationGroup="vg1" ControlToValidate="txtEmail"></asp:RegularExpressionValidator>
</div>
<!-- This is the section that is breaking the validation -->
<div style="margin-bottom:10px;">
<asp:RadioButton ID="rbOwnershipAgent" runat="server" Checked="true" GroupName="Ownership" />
<asp:RadioButton ID="rbOwnershipReferral" runat="server" GroupName="Ownership" />
</div>
<!-- --------------------------------------------------- -->
<div style="margin-bottom:10px;">
<label for="txtAgencyContact">Agency Contact Name</label>
<asp:TextBox ID="txtAgencyContact" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvAgencyContact" runat="server" ErrorMessage="*Required" ControlToValidate="txtAgencyContact" ValidationGroup="vg1" CssClass="rfvErrors"></asp:RequiredFieldValidator>
</div>
<div style="margin-bottom:10px;">
<label for="txtPhone">Telephone Number</label>
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvTelephone" runat="server" ErrorMessage="*Required" ControlToValidate="txtPhone" ValidationGroup="vg1" CssClass="rfvErrors"></asp:RequiredFieldValidator>
</div>
<div>
<label for="ddlState">State</label>
<asp:DropDownList ID="ddlState" runat="server" AppendDataBoundItems="True">
<asp:ListItem Text="Select State" Value=""></asp:ListItem>
</asp:DropDownList>
</div>
<div style="margin-bottom:10px;">
<label for="taCarriers">In your agency, who are the carriers writing liquor liability for you today?</label>
<asp:TextBox ID="taCarriers" runat="server" TextMode="MultiLine" Rows="3"></asp:TextBox><asp:RequiredFieldValidator ID="rfvOtherCarriers" runat="server" ErrorMessage="*Required" ControlToValidate="taCarriers" ValidationGroup="vg1" CssClass="rfvErrors" style="margin-top:15px;"></asp:RequiredFieldValidator>
</div>
<div style="width:100%;margin-top:20px;border-bottom:1px solid #27a0d6"></div>
<asp:Button ID="btnSubmit" runat="server" Text="Submit »" name="bnSubmit" class="submit" ValidationGroup="vg1" />
</form>
Am I missing something simple as far as an attribute on the submit button or radio buttons? I'm just surprised that a built in .Net control is causing this kind of trouble for something this basic. Thanks for any help.
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.
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...