How can I show / hide certain divs according to the selected value in the dropdownlist:
(for example, if Convert from Fahrenheit to Celsius is currently selected in the dropdown, only the conversion div is visible)
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<p>
Please choose required calculation from the following list:
<asp:DropDownList ID="calculation" runat="server">
<asp:ListItem>Addition of three numbers</asp:ListItem>
<asp:ListItem>Convert from Fahrenheit to Celsius</asp:ListItem>
<asp:ListItem>Calculate the side of a right-angled triangle</asp:ListItem>
<asp:ListItem>Find x using the Quadratic Equation</asp:ListItem>
</asp:DropDownList>
<br /><br />
</p>
<div id="addition" runat="server">
<p>
Input variable a : <asp:TextBox runat="server" ID="varA"></asp:TextBox><br /><br />
Input variable c : <asp:TextBox runat="server" ID="varB"></asp:TextBox><br /><br />
Input variable b : <asp:TextBox runat="server" ID="varC"></asp:TextBox><br /><br />
<asp:Button ID="additionSubmit" runat="server" Text="Submit"
onclick="additionSubmit_Click" /><br /><br />
<asp:Label ID="lblAddition" runat="server" Text="" CssClass="label"></asp:Label>
</p>
</div>
<div id="conversion" runat="server">
<p>
Input Fahrenheit Temperature : <asp:TextBox runat="server" ID="temperatureF"></asp:TextBox><br /><br />
<asp:Button ID="converstionSubmit" runat="server" Text="Submit"
onclick="converstionSubmit_Click" /><br /><br />
<asp:Label ID="lblConversion" runat="server" Text="" CssClass="label"></asp:Label>
</p>
</div>
<div id="triangle" runat="server">
<p>
Input side a : <asp:TextBox runat="server" ID="tsideA"></asp:TextBox><br /><br />
Input side b : <asp:TextBox runat="server" ID="tsideB"></asp:TextBox><br /><br />
<asp:Button ID="triangleSubmit" runat="server" Text="Submit"
onclick="triangleSubmit_Click" /><br /><br />
<asp:Label ID="lblTriangle" runat="server" Text="" CssClass="label"></asp:Label>
</p>
</div>
<div id="quadratic" runat="server">
<p>
Input side a : <asp:TextBox runat="server" ID="sideA"></asp:TextBox><br /><br />
Input side c : <asp:TextBox runat="server" ID="sideB"></asp:TextBox><br /><br />
Input side b : <asp:TextBox runat="server" ID="sideC"></asp:TextBox><br /><br />
<asp:Button ID="quadraticSubmit" runat="server" Text="Submit"
onclick="quadraticSubmit_Click" /><br /><br />
<asp:Label ID="lblQuadratic" runat="server" Text="" CssClass="label"></asp:Label>
</p>
</div>
Using Jquery this would work:
(document).ready(function() {
doIt();
$('#yourDropdown').change(doIt); //This is triggered on the change of the dropdown list
function doIt() {
switch ($("#yourDropdown").val()) {
case "addition" :
$("#addition").show();
$('#otherDiv').hide();
break;
case "ConvertFToC":
and so on....
}
});
})
<select id="yourDropdown">
<option value="addition">addition</option>
and so on...
</select>
<div id="addition" >
<p>
Input variable a : <asp:TextBox runat="server" ID="varA"></asp:TextBox><br /><br />
Input variable c : <asp:TextBox runat="server" ID="varB"></asp:TextBox><br /><br />
Input variable b : <asp:TextBox runat="server" ID="varC"></asp:TextBox><br /><br />
<asp:Button ID="additionSubmit" runat="server" Text="Submit"
onclick="additionSubmit_Click" /><br /><br />
<asp:Label ID="lblAddition" runat="server" Text="" CssClass="label"></asp:Label>
</p>
</div>
Related
I have a created a profile page for my website, there is a photo, upload button and a fileUpload control. Controls such as First name/ last name etc are placed In a panel separate from image and image control. The problem is that Panel leaves a huge margin from top (I haven't given margin-top). I want to remove that white space. I have tried a couple of things such as providing position (absolute/relative) and I tried to rearrange the controls but didn't work
.common
{
float: left;
position: relative;
}
.Panel
{
margin-right: 50px;
padding: 20px;
float: right;
}
.layWork
{
border: white 2px solid;
width: 800px;
background-color: white;
border-radius: 50px;
height: 700px;
margin: 50px 0px 20px 50px;
}
<div class="layWork">
<div class="Frontier">
<br />
<br />
<asp:Image ID="Shasshin" runat="server" src="../Property/EmptyIcon.png" Height="200px" Width="200px" cssClass="common"/>
<br />
<asp:Panel ID="proPan" runat="server" CssClass="Panel">
<asp:Label ID="proFNameLabel" Text="First Name : " runat="server" />
<asp:TextBox ID="proFNameBox" runat="server" Text=""/>
<br /><br />
<asp:Label ID="proLNameLabel" Text="Last Name : " runat="server" />
<asp:TextBox ID="proLNameBox" runat="server" Text="" />
<br /><br />
<asp:Label ID="proAge" Text="Age : " runat="server" />
<asp:TextBox ID="proAgeBox" runat="server" />
<br /><br />
<asp:Label ID="proBirth" Text="Birthdate : " runat="server"/>
<asp:TextBox ID="proBirthBox" runat="server"/>
<br /><br />
<asp:Label ID="proLoc" Text="Localtion : " runat="server" />
<asp:TextBox ID="proLocBox" runat="server" />
<br /><br />
<asp:Label ID="proNumber" Text="Phone : " runat="server" />
<asp:TextBox ID="proNumBox" runat="server" />
<br /><br />
<asp:Label ID="SkypeID" Text="Skype ID : " runat="server" />
<asp:LinkButton ID="proSkype" runat="server">Link</asp:LinkButton>
<br /><br />
<asp:Label ID="proDesc" Text="Description : " runat="server" />
<asp:TextBox ID="proDescBox" TextMode="MultiLine" runat="server" />
<br /><br />
<asp:Label ID="proDev" Text="Developer : " runat="server" />
<asp:TextBox ID="proDevBox" runat="server" />
</asp:Panel>
<asp:FileUpload ID="PhotoPicker" CssClass="common" runat="server" /><br />
<asp:Button ID="PhotoSender" runat="server" cssClass="common" Text="Upload" />
</div>
</div>
I use table generally ,so this may help.
<table>
<tr>
<td style="vertical-align:top"> <asp:Image ID="Shasshin" runat="server" src="../Property/EmptyIcon.png" Height="200px" Width="200px" cssClass="common"/></td>
<td> </td>
<td style="vertical-align:top"> <asp:Panel ID="proPan" runat="server" CssClass="Panel">
<asp:Label ID="proFNameLabel" Text="First Name : " runat="server" />
<asp:TextBox ID="proFNameBox" runat="server" Text=""/>
<br /><br />
<asp:Label ID="proLNameLabel" Text="Last Name : " runat="server" />
<asp:TextBox ID="proLNameBox" runat="server" Text="" />
<br /><br />
<asp:Label ID="proAge" Text="Age : " runat="server" />
<asp:TextBox ID="proAgeBox" runat="server" />
<br /><br />
<asp:Label ID="proBirth" Text="Birthdate : " runat="server"/>
<asp:TextBox ID="proBirthBox" runat="server"/>
<br /><br />
<asp:Label ID="proLoc" Text="Localtion : " runat="server" />
<asp:TextBox ID="proLocBox" runat="server" />
<br /><br />
<asp:Label ID="proNumber" Text="Phone : " runat="server" />
<asp:TextBox ID="proNumBox" runat="server" />
<br /><br />
<asp:Label ID="SkypeID" Text="Skype ID : " runat="server" />
<asp:LinkButton ID="proSkype" runat="server">Link</asp:LinkButton>
<br /><br />
<asp:Label ID="proDesc" Text="Description : " runat="server" />
<asp:TextBox ID="proDescBox" TextMode="MultiLine" runat="server" />
<br /><br />
<asp:Label ID="proDev" Text="Developer : " runat="server" />
<asp:TextBox ID="proDevBox" runat="server" />
</asp:Panel></td>
</tr>
<tr>
<td> <asp:FileUpload ID="PhotoPicker" CssClass="common" runat="server" /></td>
<td> <asp:Button ID="PhotoSender" runat="server" cssClass="common" Text="Upload" /> </td>
</tr>
</table>
I am encountering this issue:
asp.net ajax client-side framework failed to load
when I tried to open the modal popup-blocker.
How can I solve this? I've been struggling for weeks...
Here's the code for the same:
<form id="form1" runat="server">
<cc:ToolkitScriptManager ID="sc1" runat="server"></cc:ToolkitScriptManager>
<div>
<asp:Button ID="ModalCall" runat="server" OnClick="ModalCall_Click" Text="ModalCall" />
<cc:ModalPopupExtender ID="mod1" runat="server" CancelControlID="btn1" PopupControlID="pan1" TargetControlID="ModalCall"></cc:ModalPopupExtender>
<asp:Panel ID="pan1" runat="server">
<asp:Button ID="Register" runat="server" OnClick="Register_Click" Text="Register" />
<asp:TextBox ID="Email" runat="server"></asp:TextBox>
<asp:TextBox ID="Password" runat="server"></asp:TextBox>
<asp:TextBox ID="ConfirmPassword" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Login" runat="server" OnClick="Login_Click" Text="Login" />
<asp:TextBox ID="LoginEmail" runat="server"></asp:TextBox>
<asp:TextBox ID="LoginPassword" runat="server"></asp:TextBox>
<br />
<asp:Button ID="CallService" runat="server" OnClick="CallService_Click" Text="Call Service" />
<br />
<asp:Button ID="ChangePassword" runat="server" OnClick="ChangePassword_Click" Text="ChangePassword" />
<asp:TextBox ID="OldPassword" runat="server"></asp:TextBox>
<asp:TextBox ID="NewPassword" runat="server"></asp:TextBox>
<asp:TextBox ID="ConfirmChangedPassword" runat="server"></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="btn1" runat="server" Text="hide" />
</asp:Panel>
</div>
</form>
I have a listview control that is bounded by an entity query. The main listview is bounded to the entity called Article. The second listview(nested one) is bounded to an icollection of Article_Comment. I am trying to get the ID of a article so that I can use it in updating the article comment table. Below is what I have so far.
<asp:ListView ID="listComment" runat="server" DataKeyNames="ArticleID" >
<LayoutTemplate>
<div class="row">
<h3>Comments</h3>
<blockquote>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</blockquote>
</div>
</LayoutTemplate>
<ItemSeparatorTemplate>
<hr />
</ItemSeparatorTemplate>
<ItemTemplate>
<h4 class="text-error"><%#Eval("Title")%></h4>
<br />
<h4 class="text-error"><%#Eval("ArticleID")%></h4
<br />
<p><%#Eval("ArticleContent")%> </p>
<asp:ListView ID="list" runat="server" DataSource='<%# Eval("Article_CommentTable")%>'
InsertItemPosition="LastItem" OnItemCommand="list_ItemCommand" OnItemDataBound="list_ItemDataBound"
DataKeyNames="ArticleID" OnItemInserting="list_ItemInserting">
<LayoutTemplate>
<div class="row">
<h3>Comments</h3>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</div>
</LayoutTemplate>
<ItemTemplate>
<p>
Username : <%#Eval("UserName")%>
<br />
Comments : <%#Eval("Comment")%>
<br />
<%--<asp:Label ID="lblID" runat="server" Text='<%# Bind("ArticleID")%>'></asp:Label>--%>
<asp:HiddenField ID="hid" runat="server" Value='<%# Bind("ArticleID")%>' />
</p>
</ItemTemplate>
<InsertItemTemplate>
<div class="row" runat="server">
<asp:TextBox ID="txtUserName" runat="server" CssClass="form-control" />
<br />
<asp:TextBox ID="txtComment" runat="server" CssClass="form-control" />
<FCKeditorV2:FCKeditor ID="editorArticle" runat="server"
BasePath="~/FCKeditor/" Height="200px" Width="400px"
Value="Start typing here" ToolbarStartExpanded="False">
</FCKeditorV2:FCKeditor>
<br />
<asp:Button ID="btnAddComment" runat="server" CssClass="btn btn-info"
CommandName="insert" Text="Join The Discussion" CommandArgument='<%#Eval("ArticleID")%>' />
</div>
</InsertItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:ListView>
I am trying to access the ArticleID for each row that a button is clicked. How should I do that?
you can get it in ItemCommand event as listComment.DataKeys[dataItem.DisplayIndex].Value
I am using datalist for showing datas. Datas are test questions with 4 options.I have 50 questions displaying in datalist.
By using ItemDataBound event - i am making visible only one question with 4 options to user. Remaining questions are invisible . In the Itemdatabound event - i am assigning id to the radio buttons. but also id is not assigned to the datalist ,it showing different id.
<div class="widget">
<div class="widget-header" align="center" style="background: #4a98c9; color: #FFFFFF;">
<h4>
<asp:Label ID="Label5" runat="server" Text="Question : "></asp:Label>
<asp:Label ID="lblQuestionNo" runat="server" Text="0 of 0"></asp:Label></h4>
<asp:HiddenField ID="HdCurrentQuestSlNo" runat="server" />
<asp:HiddenField ID="HdfMinTime" runat="server" />
<asp:HiddenField ID="HdfSecTime" runat="server" />
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:HiddenField ID="HdfQSlNo" runat="server" />
<asp:HiddenField ID="HdQuestCount" runat="server" Value="0"/>
</div>
<div class="widget-content">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="PanelQuestBlock" runat="server" ScrollBars="Vertical" Width="100%" Height="325px">
<asp:DataList runat="server" ID="DataListQuestion"
onitemdatabound="DataListQuestion_ItemDataBound"
onitemcreated="DataListQuestion_ItemCreated">
<ItemTemplate>
<div class="questdisplayId" id="divQuestBlock" runat="server">
<div>
<asp:HiddenField ID='HdSlNo' runat="server" Value='<%# Eval("SlNo") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdUserQuestId" runat="server" Value='<%# Eval("UserQuestionId") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdTotalOptions" runat="server" Value='<%# Eval("TotalOptions") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdQuestAnsweredTimeSecs" runat="server" Value='<%# Eval("AnsweredTimeSecs") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdOptionAnswered" runat="server" Value='<%# Eval("OptionAnswered") %>' ClientIDMode="Static"/>
</div>
<div>
<asp:Label ID="Question" runat="server" Text='<%# Eval("Question") %>'></asp:Label>
</div>
<div class="answer-row" id="divOption1" runat="server">
<asp:RadioButton ID="Option1" runat="server" GroupName="Answer" value="1" Text='<%# Eval("Option1") %>'
CssClass="rdbtn" Style="vertical-align: middle" ClientIDMode="Static"/>
<asp:Label ID="lblOpt1" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption2" runat="server">
<asp:RadioButton ID="Option2" runat="server" GroupName="Answer" value="2" Text='<%# Eval("Option2") %>'
CssClass="rdbtn" Style="vertical-align: middle" ClientIDMode="Static"/>
<asp:Label ID="lblOpt2" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption3" runat="server">
<asp:RadioButton ID="Option3" runat="server" GroupName="Answer" value="3" Text='<%# Eval("Option3") %>'
CssClass="rdbtn" Style="vertical-align: top; left: auto;" ClientIDMode="Static"/>
<asp:Label ID="lblOpt3" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption4" runat="server">
<asp:RadioButton ID="Option4" runat="server" GroupName="Answer" value="4" Text='<%# Eval("Option4") %>'
CssClass="rdbtn" Style="vertical-align: text-top" ClientIDMode="Static"/>
<asp:Label ID="lblOpt4" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption5" runat="server">
<asp:RadioButton ID="Option5" runat="server" GroupName="Answer" value="4" Text='<%# Eval("Option5") %>'
CssClass="rdbtn" Style="vertical-align: text-top" ClientIDMode="Static"/>
<asp:Label ID="lblOpt5" runat="server" Text=""></asp:Label>
</div>
</div>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div class="row">
<div class="span8" align="center">
<asp:Button ID="btnClear" runat="server" Text="Clear Selection"
CssClass="btn btn-warning" OnClientClick="Clearbutton();"
/>
<asp:Button ID="btnSave" runat="server" Text="Save & Next" CssClass="btn btn-success" OnClientClick="Savebutton()"/>
</div>
<div class="span4" align="center">
<asp:Button ID="btnReview" runat="server" Text="Mark Review & Next" CssClass="btn btn-info" OnClientClick="Reviewbutton()"/>
<asp:Button ID="btnFinish" runat="server" Text="Finish" CssClass="btn btn-danger" OnClientClick="Finishbutton()"/>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnReview" />
<asp:AsyncPostBackTrigger ControlID="btnClear" />
<asp:AsyncPostBackTrigger ControlID="btnSave" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DataListQuestion" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
HiddenField HdSlNo = (HiddenField)e.Item.FindControl("HdSlNo");
RadioButton Option1 = (RadioButton)e.Item.FindControl("Option1");
RadioButton Option2 = (RadioButton)e.Item.FindControl("Option2");
RadioButton Option3 = (RadioButton)e.Item.FindControl("Option3");
RadioButton Option4 = (RadioButton)e.Item.FindControl("Option4");
RadioButton Option5 = (RadioButton)e.Item.FindControl("Option5");
Option1.ID = "rdbtnoption1_" + HdSlNo.Value.ToString();
Option2.ID = "rdbtnoption2_" + HdSlNo.Value.ToString();
Option3.ID = "rdbtnoption3_" + HdSlNo.Value.ToString();
Option4.ID = "rdbtnoption4_" + HdSlNo.Value.ToString();
Option5.ID = "rdbtnoption5_" + HdSlNo.Value.ToString();
}
In my design page code , using Datalist i am binding 50 questions . while binding itself i am hiding 2 to 50 questions . Question 1 only visible. I tried to give dynamic id for every questions and options using event databound and rowcreated. First it got error , after that i changed properties as ClientIDMode="Static" for controls.it shown different id. But if i click any button event again it clear the id's.again it shows old ids only.
I have created an ASP.NET page with an AJAX Accordion control. Within on the panes are several controls, some of which I've placed inside a Panel control, for various reasons.
However, controls which are on the page AFTER the closing tag for the panel are appearing INSIDE the panel when the page is rendered. For the life me I can't figure out why, and it's driving me crazy! Even clicking on the header of the Accordion Pane after the one containing the panel doesn't cause the Pane to expand, which it did before I added the Panel, seemingly because even IT is behaving as if it's within the Panel!
Any ideas what I'm doing wrong? How can I make the page believe that the panel ends!!?
<asp:Accordion ID="accQuestionnaire" runat="server" RequireOpenedPane="false" ContentCssClass="AccordionContent" HeaderCssClass="AccordionHeader" FadeTransitions="true"
transitionduration="250" HeaderSelectedCssClass="AccordionSelected" SelectedIndex="0" SuppressHeaderPostbacks="true" >
<Panes>
<%--START OF Tristan Link Pane (0)-------------------------------------------------------------%>
<asp:AccordionPane ID="pnTristanLink" runat="server" ContentCssClass="AccordionContent" ViewStateMode="Enabled" >
<Header>
Tristan Link
</Header>
<Content>
<div class="centrebuttonsdiv" >
<asp:Button ID="btnSearchTristan" runat="server" CssClass="largebutton" Text="Search Tristan" /><br />
</div>
<asp:Panel ID="pnlTristanSearch" runat="server" CssClass="panel" >
<div class="leftdiv"> <%--Matching Tristan results--%>
<asp:FormView ID="fvTristanSearch" runat="server" CssClass="FormView" >
<ItemTemplate>
<asp:Label ID="lblTristanSearchLabel" runat="server" CssClass="fieldtitle" Text="The information from Tristan for this Case Number is:" /><br /><br />
<asp:Label ID="lblAnimalNameLabel" runat="server" CssClass="fieldtitle" Text="Horse Name: " />
<asp:Label ID="lblAnimalName" runat="server" Text='<%# Eval("PetName") & " " & Eval("ClientNameLast") %>' /><br />
<asp:Label ID="lblGenderLabel" runat="server" CssClass="fieldtitle" Text="Sex: " />
<asp:Label ID="lblGender" runat="server" Text='<%# Eval("L_GenderDesc") %>' /><br />
<asp:Label ID="lblBreedLabel" runat="server" CssClass="fieldtitle" Text="Breed: " />
<asp:Label ID="lblBreed" runat="server" Text='<%# Eval("L_BreedDesc") %>' /><br />
<asp:Label ID="lblDOBLabel" runat="server" CssClass="fieldtitle" Text="DOB: " />
<asp:Label ID="lblDOB" runat="server" Text='<%# Eval("PetDOB", "{0:d}") %>' /><br /><br />
</ItemTemplate>
</asp:FormView>
</div>
<div class="rightdiv">
<br /><br />
<asp:Label ID="lblUnmatchedAppointments" runat="server" Text="Appointments for this horse with no Colic Study details:" Visible="false" /><br />
<asp:ListBox ID="lstUnmatchedAppointments" runat="server" DataSourceID="SQLUnmatchedAppointments" DataTextField="AppointmentDate" DataTextFormatString="{0:d}" DataValueField="AppointmentID"
Visible = "False" />
</div>
<div class="cleardiv" />
</asp:Panel>
<div class="centrebuttonsdiv" >
<asp:Label ID="lblTristanSearchInstructions" runat="server" Text="Select an appointment from the list above and click 'Save Section' to continue. Otherwise, click 'Clear Retrieved Information'
to search again" Visible="false" /><br />
<asp:Button ID="btnClearTristanSearch" runat="server" Text="Clear Retrieved Information" Visible="false" CssClass="largebutton" />
<asp:Button ID="btnSaveTristanLink" runat="server" Text="Save Section" OnClientClick="disablePanes()" Visible="false" Enabled="false" CssClass="largebutton" />
</div>
</Content>
</asp:AccordionPane>
I believe that changing this line:
<div class="cleardiv" />
to this
<div class="cleardiv"></div>
will solve that rendering problem; <div> is not typically a self-closing tag.