I have written code in aspx file
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<section>
<div>
<label>State</label>
<label class="select">
<asp:DropDownList ID="ddlState" runat="server" DataTextField="StateName" DataValueField="StateName">
</asp:DropDownList><i></i>
</label>
</div>
</section>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountry" />
</Triggers>
</asp:UpdatePanel>
<div>
<label>Country</label>
<label class="select">
<asp:DropDownList ID="ddlCountry" runat="server" ToolTip="Select country" DataTextField="CountryName"
DataValueField="CountryID" AutoPostBack="true" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged">
</asp:DropDownList><i></i>
<asp:Label ID="lblSelectCountryFirst" Visible="false" Text="Please Select Country" runat="server" ForeColor="Red">
</asp:Label>
</label>
</div>
</section>
Now I want that when user will click on state dropdown the label lblSelectCountryFirst should be visible. How to accomplish this in jquery.
Use OnClientClick and change visible=false to css style display:none;. Please refer the solution given below:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<section>
<div>
<label>
State</label>
<label class="select">
<asp:DropDownList ID="ddlState" runat="server" DataTextField="StateName" DataValueField="StateName">
</asp:DropDownList><i></i>
</label>
</div>
</section>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountry" />
</Triggers>
</asp:UpdatePanel>
<div>
<label>
Country</label>
<label class="select">
<asp:DropDownList ID="ddlCountry" runat="server" ToolTip="Select country" DataTextField="CountryName"
DataValueField="CountryID" AutoPostBack="true" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" OnClientClick="ShowCountryLabel();">
</asp:DropDownList><i></i>
<asp:Label ID="lblSelectCountryFirst" Text="Please Select Country" runat="server" ForeColor="Red" style="Display: none;"></asp:Label>
</label>
</div>
</section>
//Jquery Code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function ShowCountryLabel(){
$("#lblSelectCountryFirst").show();
__doPostBack('__Page', '');
}
</script>
Related
I am trying to create a dynamic Multiple-choice Question Quiz, where we have different categories in which there are multiple questions with their individual options. I need to validate that at least one option is selected.
Below is the aspx code which I am using to bind the data:
<asp:ListView ID="lv_cat" runat="server" OnItemDataBound="lv_cat_ItemDataBound">
<EmptyDataTemplate></EmptyDataTemplate>
<ItemTemplate>
<div class="step">
<h4 style="text-align: center;"><%# Eval("Cat_name") %></h4>
<asp:Label ID="lbl_Cat_id" runat="server" Text='<%# Eval("cat_id") %>' hidden="true"></asp:Label>
<asp:ListView ID="Lv_question" runat="server" OnItemDataBound="Lv_question_ItemDataBound">
<EmptyDataTemplate></EmptyDataTemplate>
<ItemTemplate>
<div class="row">
<div class="col-md-10">
<h3><%# Eval("Question") %></h3>
<asp:Label ID="lbl_Q_Id" runat="server" Text='<%# Eval("Q_id") %>' hidden="true"></asp:Label>
<asp:Label ID="lbl_Q_ID_Status" runat="server" Text='<%# Eval("status") %>' hidden="true"></asp:Label>
<%-- <ul class="data-list-2">
<asp:ListView ID="Lv_Answer_check" runat="server" >
<EmptyDataTemplate></EmptyDataTemplate>
<ItemTemplate>
<li>
<input name="rate" type="checkbox" class="required check_radio" id="checkbox" value='<%# Eval("A_id") %>'><label><%# Eval("answers") %></label></li>
</ItemTemplate>
</asp:ListView>
<asp:ListView ID="Lv_Answer_Radio" runat="server" >
<EmptyDataTemplate></EmptyDataTemplate>
<ItemTemplate>
<li>
<input name="rate" type="radio" id="radiobutton" class="required check_radio" value='<%# Eval("A_id") %>'><label> <%# Eval("answers") %></label></li>
</ItemTemplate>
</asp:ListView>
</ul>
</br>--%>
<asp:RadioButtonList ID="Rbl_options" runat="server" Style="text-align: left; margin-left: 30px;" >
</asp:RadioButtonList>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" name="CheckBoxList1" Style="text-align: left; margin-left: 30px;" ></asp:CheckBoxList>
</div>
</div>
</ItemTemplate>
</asp:ListView>
</div>
</ItemTemplate>
</asp:ListView>
and below is the javascript code which I am tried to implement.
<script>
$("input[type='checkbox']").addClass("answer_check");
$(".answer_check").each(function () {
$(this).rules("add", {
required: true,
messages: {
required: "please select atleast one of the below"
}
});
}); </script>
I am trying hard to change the color of a text when it is clicked but not getting success.
There is one label for question, four labels for four options, one label for correct answer and one label for explanation.
What I am trying is when user click on any option then it should match with the correct answer and change the color of the text of that option i.e. when the answer is correct the text color should turn to green otherwise the color should turn to red .
But when I click on any option it is turning to red color only . Correct option should turn to green but it is turning to red . I can't figure out why ?.
Have a look at my code. Show me where I am making mistake and what is the solution.
.aspx :-
<%# Page Title="" Language="C#" MasterPageFile="~/Student/StudentPage.master" AutoEventWireup="true" CodeFile="studpractice.aspx.cs" Inherits="Student_studpractice" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
$(function () {
$(".optionclass").click(function () {
var $thisoption = $(this);
var $corrans = $(".correctans");
if ($thisoption.text() == $corrans.text()) {
$thisoption.css("color", "green");
} else {
$thisoption.css("color", "red");
}
});
});
</script>
<div>
<div id="tabs">
<ul>
<li>Reasoning</li>
<li>Quantitative Aptitude</li>
<li>English</li>
<li>Mathematics</li>
<li>Computer Concepts</li>
</ul>
<div id="tabs-1">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" width="100%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Question") %>'></asp:Label>
<br />
<br />
<br />
<span>A-</span> <asp:Label class="optionclass" ID="Label2" runat="server" Text='<%#Eval("Option1")%>' ></asp:Label>
<br />
<br />
<span>B-</span> <asp:Label class="optionclass" ID="Label3" runat="server" Text='<%#Eval("Option2")%>'></asp:Label>
<br />
<br />
<span>C-</span> <asp:Label class="optionclass" ID="Label4" runat="server" Text='<%#Eval("Option3")%>'></asp:Label>
<br />
<br />
<span>D-</span> <asp:Label class="optionclass" ID="Label5" runat="server" Text='<%#Eval("Option4")%>'></asp:Label>
<br />
<br />
<asp:Button class="panelButton" runat="server" Text="Show Answer" ClientIDMode="Static" />
<br />
<asp:Panel ID="anspanel" class="AnswerPanel" runat="server" ClientIDMode="Static">
<span>Correct Answer is :-</span><asp:Label class="correctans" ID="Label6" runat="server" Text='<%#Eval("CorrectAns")%>'></asp:Label>
<br />
<br />
<asp:Label ID="Label7" runat="server" Text='<%#Eval("Explanation")%>'></asp:Label>
</asp:Panel>
</asp:Panel>
<br />
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="tabs-2">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Question") %>'></asp:Label>
<br />
<br />
<br />
<span>A-</span> <asp:Label class="optionclass" ID="Label2" runat="server" Text='<%#Eval("Option1")%>'></asp:Label>
<br />
<br />
<span>B-</span> <asp:Label class="optionclass" ID="Label3" runat="server" Text='<%#Eval("Option2")%>'></asp:Label>
<br />
<br />
<span>C-</span> <asp:Label class="optionclass" ID="Label4" runat="server" Text='<%#Eval("Option3")%>'></asp:Label>
<br />
<br />
<span>D-</span> <asp:Label class="optionclass" ID="Label5" runat="server" Text='<%#Eval("Option4")%>'></asp:Label>
<br />
<br />
<asp:Button class="panelButton" runat="server" Text="Show Answer" ClientIDMode="Static" />
<br />
<asp:Panel ID="anspanel" class="AnswerPanel" runat="server" ClientIDMode="Static">
<span>Correct Answer is :-</span><asp:Label class="correctans" ID="Label6" runat="server" Text='<%#Eval("CorrectAns")%>'></asp:Label>
<br />
<br />
<asp:Label ID="Label7" runat="server" Text='<%#Eval("Explanation")%>'></asp:Label>
</asp:Panel>
</asp:Panel>
<br />
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="tabs-3">
Tab 3 Content
</div>
<div id="tabs-4">
Tab 4 Content
</div>
<div id="tabs-5">
Tab 5 Content
</div>
</div>
<input type="button" id="btnPrevious" value="Previous" style = "display:none"/>
<input type="button" id="btnNext" value="Next" />
</div>
</asp:Content>
So what wrong you are doing is you are selecting all .correctans and what you should do is select the .correctans specific to that question only.
Change $(".correctans") to $(".correctans")[0] or $(".correctans").first() to get the single correctans element instead of a collection.
EDIT:
Since you have multiple questions and answers on the page, use this to get the correctans for the question they're answering:
var $corrans = $(this).parent().find('.correctans:first');
I'm developing a Web user control
.ascx
<div style="position:relative;border:none;" id="divComboContainer" runat="server" >
<asp:HiddenField ID="Hidden_TextField" Value="" runat="server" />
<asp:HiddenField ID="Hidden_ValueField" Value="" runat="server" />
<asp:HiddenField ID="Hidden_Value" Value="" runat="server" />
<asp:HiddenField ID="Hidden_Row_Index" Value="" runat="server" />
<asp:HiddenField ID="hfScrollPosition" Value="" runat="server" />
<asp:TextBox ID="txtDisplay" runat="server" CssClass="tb10" ></asp:TextBox>
<asp:Panel ID="DropPanel" runat="server" CssClass="ContextMenuPanel"
Width="280px" style="display :none;visibility: hidden;padding-bottom:-1px;
margin-top:-28px;margin-left:0px;background-color:#F5F5F5;overflow:hidden;
height:auto;min-height:100px;max-height:300px;max-width:350px;" >
<div id="CombClose" style="padding-right:2px;color:#FFFFFF;text-align:right;cursor:pointer;height:35px;background-color:#507CD1;width:100%;" runat="server" >Close</div>
<br />
<div runat="server" id="listDiv" style="padding-bottom:-1px;margin-top:-28px;
margin-left:0px;background-color:#F5F5F5;overflow-Y:auto;overflow-X:hidden;
height:200px;max-height:265px;max-width:350px;" tabindex="0">
<asp:CheckBoxList ID="chkList" runat="server" CssClass="Chklist">
</asp:CheckBoxList>
</div>
</asp:Panel>
<ajaxToolkit:DropDownExtender runat="server" ID="DDE" TargetControlID="txtDisplay"
DropDownControlID="DropPanel" HighlightBorderColor="Transparent" OnClientPopup="OnClientPopup" />
</div>
In this control i need to fire some java-script on lostFocus or blur event.
Can any one guide me how can i call my script on control blur or lostFocus.
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