i am developing application in asp.net c#, in that i have a problem .
the problem is
i have three fields in a asp.net page, in that it having Bank Name, Branch, and IFSC Code, these three is mandatory to fill when i click save button,
but when i click search & clear button also it should ask to fill these fields.
how to restrict this when click other buttons
"please fill in this field"..
suppose if i search sbi bank only, it asks to enter every field.
MY CODE
Enter Bank
</div>
<div class="form-group col-md-3">
<label for="exampleInputEmail1">
Enter Branch</label>
<asp:TextBox ID="txtBranchName" runat="server" type="text" CssClass="form-control" PlaceHolder="Enter Branch" required />
</div>
<div class="form-group col-md-3">
<label for="exampleInputEmail1">
Enter IFSC Code</label>
<asp:TextBox ID="txtIFSCCode" runat="server" type="text" CssClass="form-control" PlaceHolder="Enter IFSC Code" required />
</div>
</td>
</tr>
</table>
<br />
<br />
<table border="0px" cellpadding="4px" cellspacing="4px" align="center" width="180px">
<tr>
<td>
<asp:Button ID="btnSave" runat="server" ValidationGroup="valInsert" Text="Save" OnClick="btnSave_Click" ToolTip="Save" CssClass="btn btn-success" />
</td>
<td>
<asp:Button ID="btnClear" runat="server" Text="Clear" OnClick="btnClear_Click" ToolTip="Clear / Refresh" CssClass="btn btn-default" />
</td>
<td>
<asp:Button ID="btnSearch" runat="server" ValidationGroup="valInsert" Text="Search" OnClick="btnSearch_Click" ToolTip="Search" CssClass="btn btn-success" /></td>
<td>
<asp:Button ID="btnPrint" runat="server" Text="Print" OnClientClick="return PrintPanel();" ToolTip="Print" CssClass="btn btn-default" />
</td>
</tr>
</table>
Try to put formnovalidate in your search button code
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" ToolTip="Search" CssClass="btn btn-success" formnovalidate />
Use the Validation Group in ASP.net
<asp:TextBox ID="txtCustomer" class="form-control" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvName" runat="server"
ControlToValidate="txtCustomer" ForeColor="Red"
ToolTip="Please enter name" ValidationGroup="Validate" Display="Dynamic">* Required</asp:RequiredFieldValidator>
<asp:Button ID="btnSave" CssClass="btn btn-default" runat="server" Text="Save" ToolTip="Save Record" ValidationGroup="Validate" OnClick="btnSave_Click"/>
<asp:Button ID="btnClear" CssClass="btn btn-default" runat="server" Text="Clear" ToolTip="Clear / Refresh" OnClick="btnClear_Click" />
<asp:Button ID="btnClose" CssClass="btn btn-default" runat="server" Text="Close" ToolTip="Go To Main form." OnClick="btnCancle_Click" />
Try using jquery/javascript for validations.
Write button search and save click events in jquery and validate as you like.
$('#btnSave').click(function(){
//code for required field validation
});
The property of search and clear button ( causes Validation ) ..you should make it false ;)
Related
Problem
I'm creating a webshop and I want to use two different modals in one form in my masterpage, one modal is to create accounts and the other modal is to log users in.
The first modal works perfect, you can open the modal with the button, the buttons inside the modal also work perfect (e.g., register and close buttons). But the other modal (log in) doesn't work, you can open the modal and close the modal, but you can't log in. So the button log in inside the modal "log in" doesn't work, I have some C# code behind that button, but it never activated the code because the button doesn't go off. I put a breakpoint just after the BtnLogin_click, but even the breakpoint doesn't go off. The thing is if I put the second modal (register) in comment, the login modal works again or there must be something wrong in form right? Any tips or advice?
Attempt
The things I tried are:
Looked at the properties of the button, then event, and it said it's onclick with the correct name. Tried to create a new button, and a new onclick event.
HTML
The 2 buttons to open the modals
<input type = "button" id="btnShowLogin" class="btn btn-primary" value = "Login" />
<input type = "button" id="btnShowRegister" class="btn btn-primary" value = "Registreer" />
Modal 1 Login (not working)
<form id="form1" runat="server">
<div class="modal fade" id="LoginModal" tabindex="-1" role="dialog" aria-labelledby="ModalTitle"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×</button>
<h4 class="modal-title" id="ModalTitle">
Login</h4>
</div>
<div class="modal-body">
<label for="txtUsername">
Username</label>
<asp:TextBox ID="txtUsername" runat="server" CssClass="form-control" placeholder="Enter Username"
/>
<br />
<label for="txtPassword">
Password</label>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" CssClass="form-control"
placeholder="Enter Password" />
<div class="checkbox">
<asp:CheckBox ID="chkRememberMe" Text="Remember Me" runat="server" />
</div>
<div id="dvMessage" runat="server" visible="false" class="alert alert-danger">
<strong>Error!</strong>
<asp:Label ID="lblMessage" runat="server" />
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btnLogin" Text="Login" runat="server" OnClick="ValidateUser" CssClass="btn btn-default" Visible="true" />
<button type="button" class="btn btn-default" data-dismiss="modal">
Close</button>
</div>
</div>
</div>
</div>
Modal 2 register (working)
<div class="modal fade" id="RegisterModal" tabindex="-2" role="dialog" aria-labelledby="Registreer"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×</button>
<h4 class="modal-title" id="Registreer">
Registreer</h4>
</div>
<div class="modal-body">
<label for="TxtVnaam">
Voornaam</label>
<asp:TextBox ID="TxtVnaam" runat="server" CssClass="form-control" placeholder="Enter Voornaam"
/>
<label for="Txtnaam">
Achternaam
</label>
<asp:TextBox ID="Txtnaam" runat="server" CssClass="form-control" placeholder="Enter Achternaam"
/>
<br />
<label for="TxtNick">
Username</label>
<asp:TextBox ID="TxtNick" runat="server" CssClass="form-control" placeholder="Enter Username"
/>
<label for="txtEmail">
Email</label>
<asp:TextBox ID="txtEmail" runat="server" CssClass="form-control" placeholder="Enter Email"
/>
<br />
<asp:RequiredFieldValidator ErrorMessage="Required" Display="Dynamic" ForeColor="Red"
ControlToValidate="txtEmail" runat="server" />
<asp:RegularExpressionValidator runat="server" Display="Dynamic" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtEmail" ForeColor="Red" ErrorMessage="Invalid email address." />
<label for="txtWW">
Wachtwoord</label>
<asp:TextBox ID="TxtWW" runat="server" CssClass="form-control" placeholder="Enter Wachtwoord"
/>
<label for="bevestig">
Bevestig Wachtwoord</label>
<asp:TextBox ID="bevestig" runat="server" CssClass="form-control" placeholder="Enter Wachtwoord"
/><asp:CompareValidator ErrorMessage="Passwords do not match." ForeColor="Red" ControlToCompare="txtWW"
ControlToValidate="bevestig" runat="server" />
<label for="TxtGemeente">
Gemeente</label>
<asp:TextBox ID="TxtGemeente" runat="server" CssClass="form-control" placeholder="Enter Gemeente"
/>
<label for="TxtPC">
Postcode</label>
<asp:TextBox ID="TxtPC" runat="server" CssClass="form-control" placeholder="Enter Postcode"
/>
<br />
<label for="TxtAdres">
Adres</label>
<asp:TextBox ID="TxtAdres" runat="server" CssClass="form-control" placeholder="Enter adres"
/>
<br />
<label for="TxtTel">
Telefoonnummer</label>
<asp:TextBox ID="TxtTel" runat="server" CssClass="form-control" placeholder="Enter Telefoonnummer"
/>
<label for="TxtRek">
Rekeningnummer</label>
<asp:TextBox ID="TxtRek" runat="server" CssClass="form-control" placeholder="Enter rekeningnummer"
/>
<br />
</div>
<div class="modal-footer">
<asp:Button ID="Button1" Text="Registreer" runat="server" OnClick="RegisterUser" Class="btn btn-primary" />
<button type="button" class="btn btn-default" data-dismiss="modal">
Close</button>
</div>
</div>
</div>
</div>
</form>
JavaScript
<script type="text/javascript" src='https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js'></script>
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js'></script>
<script type="text/javascript">
$(function () {
$("#btnShowLogin").click(function () {
$('#LoginModal').modal('show');
});
});
$(function () {
$("#btnShowRegister").click(function () {
$('#RegisterModal').modal('show');
});
});
</script>
I expect that the button login inside the modal login will active so it can use the code I put behind it and validate the user.
you have to set ValidationGroup attribute for RequiredFieldValidator for registering .
for example :
<asp:RequiredFieldValidator ValidationGroup="register" ErrorMessage="Required" Display="Dynamic" ForeColor="Red"
ControlToValidate="txtEmail" runat="server" />
when use asp validators you should set ValidationGroup attribute because in your case you have 2 submit buttons and when you click on log in button validator of registration show the message in hidden modal and form will not submit.
I try to ajaxify RadNumericTextBoxs in Edit Form of Rad grid using (RadAjaxManager or RadAjaxManagerProxy) but i failed .
all i want to do is :
when text changed of (txt_CashAndEquivalents,txt_ShortTermInvestments) sum the values of both text boxes and set the result in txt_OneTotal without full postback .
<EditFormSettings EditFormType="Template">
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column">
</EditColumn>
<FormTemplate>
<div class="FinancePositioncontainers">
<div class="FinancePosition-container" id="decorationZone">
<h4>Finance</h4>
<fieldset>
<legend>List</legend>
<div class="formRow" style="padding-right: 10px; padding-left: 10px;">
<h5>Bal</h5>
<label for="txt_CashAndEquivalents">bal1:</label>
<telerik:RadNumericTextBox ID="txt_CashAndEquivalents" runat="server" Text='<%# Eval("CashAndEquivalents")%>' Type="Number" DataType="System.Decimal" Width="160" NumberFormat-GroupSizes="3" AutoPostBack="True" TabIndex="1" OnTextChanged="txt_CashAndEquivalents_TextChanged"></telerik:RadNumericTextBox>
<div>
</div>
<label for="txt_ShortTermInvestments">bal2:</label>
<telerik:RadNumericTextBox ID="txt_ShortTermInvestments" runat="server" Text='<%# Eval("ShortTermInvestments")%>' Type="Number" DataType="System.Decimal" Width="160" NumberFormat-GroupSizes="3" TabIndex="2" AutoPostBack="True" OnTextChanged="txt_CashAndEquivalents_TextChanged"></telerik:RadNumericTextBox>
<div>
</div>
<hr />
<label for="txt_OneTotal">total :</label>
<telerik:RadNumericTextBox ID="txt_OneTotal" runat="server" ReadOnly="true" Type="Number" DataType="System.Decimal" Width="160" NumberFormat-GroupSizes="3"></telerik:RadNumericTextBox>
<div>
</div>
</div>
<asp:LinkButton ID="btnUpdate" runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
ValidationGroup="Main" CssClass="btn btn-primary btn-xs white_cr"><span class="glyphicon glyphicon-floppy-disk"></span> <%# (Container is GridEditFormInsertItem) ? "Uppdate" %>
</asp:LinkButton>
<asp:LinkButton ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
CssClass="btn btn-primary btn-xs white_cr"><span class="glyphicon glyphicon-ban-circle"></span>Cancel</asp:LinkButton>
<br />
<br />
</div>
</div>
</FormTemplate>
</EditFormSettings>
One approach you can consider is to utilise the client event, OnValueChanged of RadNumbericTextBox control, instead of the server side event.
For example,
<telerik:RadNumericTextBox ID="txt_CashAndEquivalents" runat="server" Text='<%# Eval("CashAndEquivalents")%>' Type="Number" DataType="System.Decimal" Width="160" NumberFormat-GroupSizes="3" TabIndex="1">
<ClientEvents OnValueChanged="DoSum" />
</telerik:RadNumericTextBox>
<script type="text/javascript">
function DoSum(sender, eventArgs)
{
var txt_ShortTermInvestments = $find('<%=txt_ShortTermInvestments.ClientID %>');
var txt_OneTotal = $find('<%=txt_ShortTermInvestments.ClientID %>');
var val_CashAndEquivalents = sender.get_value();
var val_ShortTermInvestments = txt_ShortTermInvestments.get_value();
txt_OneTotal.set_value(val_CashAndEquivalents + val_ShortTermInvestments);
}
</script>
Above code is just demonstrating the idea and hasn't been tested. So give it a go and see if it works for you or not.
For more details on the available client side events, please refer to the following link.
http://docs.telerik.com/devtools/aspnet-ajax/controls/numerictextbox/client-side-programming/radnumerictextbox-client-object#radnumerictextbox-client-object
working from the validation example:
http://www.w3schools.com/aspnet/showaspx.asp?filename=demo_validationsum
using asp.net I would like to display the error message 'You must enter a value in the following fields:' to include the field name that is wrong, when data is incorrectly entered.
so far the user cant continue until the correct data is entered and a red * appears beside the column. I would now like to add the error message.
<div id="floater_EditData_Panel_popup" title="Feature Information" class="floaterDiv">
Select a feature to view/edit feature information.
<p> </p>
<asp:UpdatePanel runat="server" id="UpdatePanelDetails1" updatemode="Conditional" Childrenastriggers="false">
<ContentTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server" >
</asp:PlaceHolder>
<br />
<br />
<div id="EditDataPanelMessageOutput" style="color:Red;">
<asp:ValidationSummary ID="ValidationSummary1"
HeaderText="You must enter a value in the following fields:"
DisplayMode="BulletList"
EnableClientScript="true"
runat="server"/>
</div>
<div id="FeatureMeasureOutput"></div>
<br />
<br />
<div class="buttonwrap">
<div id="Span2" class="ActionBtns" style="display: inline-block;" >
<asp:button runat="server" id="UpdateButton" value="Save" Text="Save" OnClientClick="ValidateEditData();" CausesValidation="true" ValidationGroup="g_currentSelectedLayerName" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
function ValidateEditData() {
if (Page_ClientValidate(g_currentSelectedLayerName)) {
//alert('it is valid');
updateFeature();
return true;
}
else {
//alert('Data not valid');
return false;
}
}
Shouldnt the validation summary tag apply to the entire page?
How about:
<asp:ValidationSummary ID="ValidationSummary1"
HeaderText="You must enter a value in the following fields:"
DisplayMode="BulletList"
EnableClientScript="true"
ValidationGroup="g_currentSelectedLayerName"
runat="server"/>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" Display="Dynamic" ControlToValidate="txtFirstName" ErrorMessage="First Name is required" ValidationGroup="g_currentSelectedLayerName"></asp:RequiredFieldValidator>
<asp:Button runat="server" Text="Submit" ValidationGroup="g_currentSelectedLayerName" />
And then add an appSetting to your web.config:
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
I have an asp.net 4.5 create user form where the first 2 steps are laid out using the TemplatedWizardStep.
In step 2 I have some javascript that is supposed to react to radio button click actions.
I originally had the radio actions in step 1 and the javascript worked as expected.
Since I moved it to step 2, it no longer works.
I went to firebug and set a watch on the script, but the script was not available in step 2. In page source view none of the controls for step 2 were included, only controls from step 1. I was on step 2 when I checked page source view.
Does anyone know how to make this work as expected?
Thanks
Create User Wizard
<asp:CreateUserWizard runat="server" ID="RegisterUser" LoginCreatedUser="false" ViewStateMode="Disabled"
OnCreatedUser="RegisterUser_CreatedUser" ActiveStepIndex="0"
AnswerRequiredErrorMessage="Please answer selected question"
DuplicateUserNameErrorMessage="The user name is already in the system. Enter another user name.">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" />
<asp:PlaceHolder runat="server" ID="navigationPlaceholder" />
</LayoutTemplate>
<WizardSteps>
<asp:TemplatedWizardStep ID="wzdStep1" runat="server" StepType="Start">
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanelStep1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<fieldset>
<ul>
<li>
<asp:Label ID="lblFullName" runat="server" AssociatedControlID="txtFullName">Full name</asp:Label>
<input runat="server" data-rule-minlength="2" data-rule-required="true" class="controltext" type="text" placeholder="Enter Full Name" id="txtFullName" />
</li>
<li>
<asp:Label ID="lblCountry" runat="server" AssociatedControlID="ddCountry">Country</asp:Label>
<asp:DropDownList ID="ddCountry" AppendDataBoundItems="true" AutoPostBack="true" DataSourceID="lnqCountry" DataTextField="CntryName" DataValueField="CntryID" CssClass="controltext" runat="server">
<asp:ListItem Value="-1">---Select Country---</asp:ListItem>
</asp:DropDownList>
<asp:LinqDataSource ID="lnqCountry" runat="server"
ContextTypeName="ClientStudio.SalonDataClassesDataContext" OrderBy="CntryName"
TableName="CntrysLUs">
</asp:LinqDataSource>
</li>
<li>
<asp:Label ID="lblStates" runat="server" AssociatedControlID="ddStates">State</asp:Label>
<div class="input-append controltext" id="divStateSelect" style="display: inline-block">
<asp:DropDownList ID="ddStates" data-rule-required="true" AutoPostBack="false" EnableViewState="true" AppendDataBoundItems="true" DataSourceID="lnqStates" DataTextField="StateName" DataValueField="StateID" CssClass="controltext" runat="server">
<asp:ListItem Value="-1">---Select State---</asp:ListItem>
</asp:DropDownList>
<button class="button button-basic" id="btnAddState" onclick="addState();" type="button">
Add
</button>
</div>
<div class="input-append input-prepend" id="divStateAdd" style="display: none">
<span class="add-on">
<i class="icon-edit"></i>
</span>
<input class="controltext" runat="server" id="txtStateName" type="text" placeholder="Enter State Name" />
<button class="button button-basic" runat="server" id="btnSaveState" onclick="saveState">
Save!
</button>
<button class="button button-basic" onclick="clearState();" id="btnClearState" type="button">
Clear
</button>
</div>
<asp:LinqDataSource ID="lnqStates" runat="server"
ContextTypeName="ClientStudio.SalonDataClassesDataContext" OrderBy="StateName"
TableName="StatesLUs" Where="CntryID == #CntryID"
Select="new (StateID, StateName, CntryID)">
<WhereParameters>
<asp:ControlParameter ControlID="ddCountry" Name="CntryID"
PropertyName="SelectedValue" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
</li>
<li>
<asp:Label ID="lblCity" runat="server" AssociatedControlID="txtCity">City Name</asp:Label>
<input runat="server" data-rule-minlength="2" data-rule-required="true" class="controltext" type="text" placeholder="Enter City Name" id="txtCity" />
</li>
</ul>
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
<CustomNavigationTemplate>
<div class="pull-right">
<asp:Button ID="Button1" runat="server" CssClass="btn btn-success btn-large" CommandName="MoveNext" Text="Next" />
</div>
</CustomNavigationTemplate>
</asp:TemplatedWizardStep>
<asp:TemplatedWizardStep ID="wzdStep2" StepType="Auto">
<ContentTemplate>
<fieldset>
<ul>
<li>
<asp:Label ID="lblStylist" runat="server" AssociatedControlID="RadioButtonList1">Do you currently have a stylist or stylists?</asp:Label>
<asp:RadioButtonList ID="RadioButtonList1" AutoPostBack="false" onclick="javascript:radio(this);" CssClass="controltext"
RepeatLayout="Table" RepeatDirection="Vertical" RepeatColumns="1"
runat="server">
<asp:ListItem Value="1" Selected="True"> <i> Yes, I have a stylist(s) I see on a regular basis</i></asp:ListItem>
<asp:ListItem Value="0"> <i> No, I am looking for a new stylist</i></asp:ListItem>
</asp:RadioButtonList>
</li>
<li id="liSearch" style="display: block">
<asp:Label ID="Label1" runat="server">Find by Salon or Stylist Name</asp:Label>
<div class="clear"></div>
<br />
<div class="input-append input-prepend">
<span class="add-on">
<i class="icon-search"></i>
</span>
<input class="controltext" type="text" id="FindBySalon" placeholder="Enter Salon Name..."></input>
<button class="button button-basic" onclick="findBySalon();" id="btnFindBySalon" type="button">
Find by Salon!
</button>
</div>
<div class="clear"></div>
<div class="input-append input-prepend">
<span class="add-on">
<i class="icon-search"></i>
</span>
<input class="controltext" type="text" id="FindByStylist" placeholder="Enter Stylists Name..."></input>
<button class="button button-basic" onclick="findByStylist();" id="btnFindByStylist" type="button">
Find by Stylists Name!
</button>
</div>
</li>
<li id="liResults" style="display: none">
<asp:Label ID="lblResults" runat="server" AssociatedControlID="ddResults">Search Results</asp:Label>
<asp:DropDownList ID="ddResults" AutoPostBack="true" OnSelectedIndexChanged="ddResults_SelectedIndexChanged" CssClass="controltext" DataValueField="StylistID" DataTextField="Results" runat="server"></asp:DropDownList>
</li>
<li id="liSelf" style="display: none">
<asp:Label ID="Label2" runat="server" AssociatedControlID="ddSelf">Is this you?</asp:Label>
<asp:DropDownList ID="ddSelf" CssClass="controltext" DataValueField="CustomerID" DataTextField="Results" runat="server"></asp:DropDownList>
</li>
</ul>
</fieldset>
</ContentTemplate>
<CustomNavigationTemplate>
<div class="pull-right">
<asp:Button ID="Button2" runat="server" CssClass="btn btn-success btn-large" CommandName="MovePrevious" Text="Previous" />
<asp:Button ID="Button3" runat="server" CssClass="btn btn-success btn-large" CommandName="MoveNext" Text="Next" />
</div>
</CustomNavigationTemplate>
</asp:TemplatedWizardStep>
<asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep">
<ContentTemplate>
<p class="message-info">
Passwords are required to be a minimum of <%: Membership.MinRequiredPasswordLength %> characters in length.
</p>
<p class="validation-summary-errors">
<asp:Literal runat="server" ID="ErrorMessage" />
</p>
<fieldset>
<ol>
<li>
<asp:Label runat="server" AssociatedControlID="UserName">User name</asp:Label>
<asp:TextBox runat="server" ID="UserName" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="UserName"
CssClass="field-validation-error" ErrorMessage="The user name field is required." />
</li>
<li>
<asp:Label runat="server" AssociatedControlID="Email">Email address</asp:Label>
<asp:TextBox runat="server" ID="Email" TextMode="Email" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="Email"
CssClass="field-validation-error" ErrorMessage="The email address field is required." />
</li>
<li>
<asp:Label runat="server" AssociatedControlID="Password">Password</asp:Label>
<asp:TextBox runat="server" ID="Password" TextMode="Password" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="Password"
CssClass="field-validation-error" ErrorMessage="The password field is required." />
</li>
<li>
<asp:Label runat="server" AssociatedControlID="ConfirmPassword">Confirm password</asp:Label>
<asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword"
CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The confirm password field is required." />
<asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword"
CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The password and confirmation password do not match." />
</li>
<li>
<asp:Label ID="lblSecurityQ" runat="server" AssociatedControlID="Question">Select Security Question</asp:Label>
<asp:DropDownList ID="Question" CssClass="controltext" runat="server">
<asp:ListItem>What is your mother's maiden name?</asp:ListItem>
<asp:ListItem>What city were you born in?</asp:ListItem>
<asp:ListItem>What city was your mother born in?</asp:ListItem>
<asp:ListItem>What is your favorite sport?</asp:ListItem>
<asp:ListItem>What is your favorite pets name?</asp:ListItem>
<asp:ListItem>What grade school did you graduate from?</asp:ListItem>
<asp:ListItem>What is your favorite meal?</asp:ListItem>
<asp:ListItem>What is your favorite soap?</asp:ListItem>
</asp:DropDownList>
</li>
<li>
<asp:Label ID="lblSecurityAns" runat="server" AssociatedControlID="Answer">Security Answer</asp:Label>
<asp:TextBox ID="Answer" CssClass="controltext" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Answer"
CssClass="field-validation-error" Display="Dynamic" ErrorMessage="Please enter the answer to selected question above." />
</li>
</ol>
</fieldset>
</ContentTemplate>
<CustomNavigationTemplate>
<div class="pull-right">
<asp:Button ID="Button4" runat="server" CssClass="btn btn-success btn-large" CommandName="MovePrevious" Text="Previous" />
<asp:Button ID="Button5" runat="server" CssClass="btn btn-success btn-large" CommandName="MoveNext" Text="Next" />
</div>
</CustomNavigationTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="wzdComplete">
<ContentTemplate>
<p>
Your account has been created, but before you can login you must first verify your email address.
</p>
<p>
A message has been sent to the email address you specified. Please check your email inbox and follow the instructions in that email to verify your account.
</p>
<br />
</ContentTemplate>
<CustomNavigationTemplate>
<asp:Button ID="Button6" runat="server" CssClass="btn btn-success btn-large" CommandName="MovePrevious" Text="Previous" />
<asp:Button ID="Button7" runat="server" CssClass="btn btn-danger btn-large" CommandName="Cancel" Text="Cancel" />
<asp:Button ID="Button8" runat="server" CssClass="btn btn-primary btn-large" CommandName="MoveComplete" Text="Next" />
</CustomNavigationTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
JavaScript
<script type="text/javascript">
function radio(cnt) {
var radioButtons = document.getElementById("ContentPlaceHolder1_RegisterUser_ctl05_RadioButtonList1");
var inputs = radioButtons.getElementsByTagName("input");
var li = document.getElementById("liSearch");
var liResults = document.getElementById("liResults");
var liSelf = document.getElementById("liSelf");
if (inputs[1].checked) {
li.style.display = "none";
liResults.style.display = "none";
liSelf.style.display = "none";
} else {
li.style.display = "block";
liResults.style.display = "block";
liSelf.style.display = "block";
}
}
</script>
I suppose that you set by hand the id
ContentPlaceHolder1_RegisterUser_ctl05_RadioButtonList1
and that id change when you move it to step2.
Change it to dynamic get the id as:
var radioButtons = document.getElementById("<%=RadioButtonList1.ClientID%>");
and it will work.
I have a login box that I need to have submitted when enter is pressed. Below you are going to find part of the code. Please any help would be appreciated.
<div class="box-login clearfix">
<div class="box-login-header">
<h3>
Registered Users</h3>
</div>
<div>
<asp:Label ID="LblMessage" runat="server" ForeColor="Red"></asp:Label>
<asp:RequiredFieldValidator ID="Rfv_LoginId" runat="server" ControlToValidate="TextLogInId"
ErrorMessage="Login Id is required" ValidationGroup="A" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RevLoginId" runat="server" ControlToValidate="TextLogInId"
ErrorMessage="Login id does not contain spaces,double quotes or +><=';:,|/"
ValidationExpression="[^ "+><=':,|/]*$" ValidationGroup="A" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="Rfv_Password" runat="server" ControlToValidate="TextPassword"
ErrorMessage="Password is required" ValidationGroup="A" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="CvPassword" runat="server" ClientValidationFunction="ValidatePassword"
ControlToValidate="TextPassword" ErrorMessage="" Display="Dynamic"></asp:CustomValidator>
<asp:RegularExpressionValidator ID="RevPassword" runat="server" ControlToValidate="TextPassword"
ErrorMessage="Space is not allowed" ValidationExpression="[^ ]*$" ValidationGroup="A"
Display="Dynamic"></asp:RegularExpressionValidator>
<asp:Label ID="LblPassword" runat="server" ForeColor="#FF0066"></asp:Label>
</div>
<p>
Please enter your GoCCL.com Login ID & Password below</p>
<ul>
<li>
<label for="cloginid">
Login ID:</label>
<asp:TextBox ID="TextLogInId" runat="server" CssClass="text-box" MaxLength="16" onblur="ClearMessage()"></asp:TextBox>
</li>
<li>
<label for="cpassword">
Password:</label>
<asp:TextBox ID="TextPassword" runat="server" TextMode="Password" CssClass="text-box"
MaxLength="16" onblur="ClearMessage()"></asp:TextBox>
</li>
</ul>
<asp:LinkButton ID="btnForgotPassword" CssClass="forgot" runat="server" Text="Forgot your Login ID or Password?"
OnClick="btnForgotPassword_Click"></asp:LinkButton>
<asp:ImageButton ID="CmdLogin" CssClass="btn-login" OnClick="CmdLogin_OnClick" OnClientClick="ClearMessage()"
runat="server" ImageUrl="/stylesheets/bookccl/images/button/btn-login.gif" CausesValidation="true" />
<div class="box-login-fotter clearfix">
<p>
<strong>New to GoCCL? </strong>
<asp:LinkButton ID="btnRegistration" runat="server" Text="Register Now" CssClass="register-new"
OnClick="btnRegistration_Click"></asp:LinkButton>
to join the fun!</p>
</div>
</div>
You could wrap it in a Panel control and set the DefaultButton to the button you want invoked when pressing Enter. There are also other options explored here:
http://www.beansoftware.com/asp.net-tutorials/accept-enter-key.aspx