I'm a junior in high school in a software engineer and web development class. My issue is i assigned a value to many of my asp control objects; however, i cannot figure out how to add and display their values. Here is my code:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="pc.aspx.cs" Inherits="pc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Millennium Computers Online Order Form</title>
<link href="computer.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form name="c_order" id="c_order" runat="server"
action="pc.aspx" method="post">
<table id="tb1" cellpadding="5" cellspacing="5" border="0" >
<tr>
<!-- Logo and header information -->
<td id="header" style="height: 65px">
<img src="mclogog.jpg" alt="heading" />
</td>
</tr>
<asp:Panel runat="server" ID="frmMillenium" >
<!-- Shipping info -->
<tr>
<td id="specifications">
<fieldset class="spec">
<legend id="bill">Specifications</legend>
<table width="100%" id="specs"> <!-- 100% -->
<tr>
<td><label for="fname" >Frame Color<span>*</span></label></td>
<td><input type="text" name="fname" id="fname" size="27" />
</td>
</tr>
<tr>
<td><label for="address1">Keyboard Color<span>*</span></label></td>
<td><input type="text" name="address1" id="address1" size="57" /></td>
</tr>
<tr>
<td><label for="city">Touchpad Color<span>*</span></label></td>
<td><input type="text" name="city" id="city" size="40" />
</tr>
<tr>
<td colspan="2" id="ast">
* = Required field, must be filled in. <%-- <input id="news" type="checkbox" align="left" /> <label id="news">Check here if you'd like to receive our newsletter</label> --%>
</td>
</td>
</tr>
</table>
</fieldset>
<p id="infotext">About Us</p>
<p id="info">Welcome to Millenium Computers. Our website is designed to allow users to create their own computer. Our job is to make a computer most suited
for you, and accomadate prices as well. We offer many differant computer features with our standard designed model. We have been building computers for over
20 years and we garuntee customer satisfaction. So, what are you waiting for? Build your computer now!</p>
</td>
</tr>
<!-- End Shipping info -->
<!-- Computer Options -->
<tr>
<td>
<fieldset class="build">
<legend>Your Computer</legend>
<table width="100%">
<tr>
<td><label for="proc">Processor speed:</label></td>
<td><asp:DropDownList name="proc" ID="proc" runat="server">
<asp:ListItem value="ghz">2.4 GHz: $158</asp:ListItem>
<asp:ListItem value="3.2ghz">3.2 GHz: $184</asp:ListItem>
<asp:ListItem value="4ghz">4.0 GHz: $200</asp:ListItem>
</asp:DropDownList>
<%--<select name="proc" id="proc">
<option>2.4 GHz: $158</option>
<option>3.2 GHz: $184</option>
<option>4.0 GHz: $200</option>
</select>--%></td>
<td><label for="mem" id="memory">Memory:</label></td>
<td><asp:DropDownList name="mem" ID="mem" runat="server">
<asp:ListItem value="1gb">1 GB: $20</asp:ListItem>
<asp:ListItem value="2gb">2 GB: $30</asp:ListItem>
<asp:ListItem value="4gb">4 GB: $80</asp:ListItem>
<asp:ListItem value="8gb">8 GB: $180</asp:ListItem>
</asp:DropDownList><%--<select name="mem" id="mem">
<option>1 GB: $20</option>
<option>2 GB: $30</option>
<option value="4">4 GB: $80</option>
<option>8 GB: $180</option>
</select>--%></td>
</td>
<td rowspan="3" id="buildxtrs">
<span id="txtExtras">Extra's</span><span id="chk">(check what you want)</span><br />
<%--<input id="dvd" name="dvd" type="checkbox" />--%>
<asp:checkbox for="dvd" id="dvd" runat="server" />
<label for="dvd" id="dvdop">DVD player: $80</label><br />
<%--<input id="cdb" name="cdb" type="checkbox" />--%>
<asp:checkbox for="cdb" id="cdb" runat="server" />
<label for="cd-b" id="cd-bop">CD burner: $30</label><br />
<%--<input id="dvb" name="dvb" type="checkbox" />--%>
<asp:checkbox for="dvb" id="dvb" runat="server" />
<label for="dv-b" id="dv-bop">DVD burner: $110</label><br />
<%--<input id="lan" name="lan" type="checkbox" />--%>
<asp:checkbox for="lan" id="lan" runat="server" />
<label for="lan" id="lanop">LAN card: $45</label><br />
<%--<input id="mdm" name="mdm" type="checkbox" />--%>
<asp:checkbox for="mdm" id="mdm" runat="server" />
<label for="mdm" id="mdmop">Modem: $90</label><br />
</td>
</tr>
<tr>
<td><label for="hd">Hard Drive Size:</label></td>
<td><asp:DropDownList name="hd" ID="hd" runat="server">
<asp:ListItem value="240gb">240 GB: $80</asp:ListItem>
<asp:ListItem value="500gb">500 GB: $100</asp:ListItem>
<asp:ListItem value="750gb">750 GB: $150</asp:ListItem>
<asp:ListItem value="1tb">1 TB: $219</asp:ListItem>
</asp:DropDownList>
<%--<select name="hd" id="hd">
<option>240 GB: $80</option>
<option>500 GB: $100</option>
<option>750 GB: $150 </option>
<option>1 TB: $219</option>
</select>--%></td>
<td><label for="mtr" id="monitor">Monitor Size:</label></td>
<td><asp:DropDownList name="mtr" ID="mtr" runat="server">
<asp:ListItem value="15">15": $100</asp:ListItem>
<asp:ListItem value="17">17": $500</asp:ListItem>
<asp:ListItem value="19">19": $760</asp:ListItem>
<asp:ListItem value="21">21": $830</asp:ListItem>
</asp:DropDownList>
<%--<select name="mtr" id="mtr">
<option>15": $100</option>
<option>17": $500</option>
<option>19": $760</option>
<option>21": $830</option>
</select> --%></td>
</tr>
<tr>
<td><label for="cdr">USB Ports:</label></td>
<td><asp:DropDownList name="cdr" ID="cdr" runat="server">
<asp:ListItem value="1port">1 Port: No Charge</asp:ListItem>
<asp:ListItem value="2port">2 Ports: $30</asp:ListItem>
<asp:ListItem value="3port">3 Ports: $120</asp:ListItem>
<asp:ListItem value="4port">4 Ports: $218</asp:ListItem>
</asp:DropDownList>
<%--<select name="cdr" id="cdr">
<option>1 Port: No Charge</option>
<option>2 Ports: $30</option>
<option>3 Ports: $120</option>
<option>4 Ports: $218</option>
</select>--%></td>
</tr>
</fieldset>
</td>
</tr>
</table>
<!-- Payment information -->
<tr>
<td>
<fieldset class="case">
<legend>Computer Case (Optional)</legend>
<img src="51.99g.png" alt="Fire Case" style="height:100px;" />
<%-- start here for radio buttons--%>
<asp:RadioButton id="Radio1" value="fire" GroupName="plan" name="plan" runat="server"/><label for="plan">$51.99</label>
<%--<input type="radio" id="Radio1" value="1" name="plan" />--%>
<img src="69.99g.png" alt="Black Case" style="height:100px;" />
<asp:RadioButton id="Radio2" value="black" GroupName="plan" name="plan" runat="server"/><label for="plan">$69.99</label>
<%--<input type="radio" id="Radio2" value="2" name="plan" />--%>
<img src="149.99g.png" alt="Blue-Orange Case" style="height:100px;" />
<label for="plan3"><input type="radio" id="Radio3" value="3" name="plan" />$149.99</label>
</fieldset>
<fieldset class="pay">
<legend id="pay" >Payment Information</legend>
<table width="100%">
<tr>
<td><label for="card">Credit Card:</label></td>
<td><select id="card" name="card">
<option>Visa</option>
<option>Master Card</option>
<option>American Express</option>
<option>Discover</option>
</select>
<label for="exp">Expires On:</label>
<select id="exp" name="exp">
<option>01</option><option>02</option><option>03</option><option>04</option>
<option>05</option><option>06</option><option>07</option><option>08</option>
<option>09</option><option>10</option><option>11</option><option>12</option>
</select> /
<select>
<option>2006</option>
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option><option>2013</option>
</select></td>
<tr>
<td><label for="cname">Name On Card:</label></td>
<td><input id="cname" name="cname" type="text" size="53" /></td>
</tr>
<tr>
<td><label for="cnum">Card Number:</label></td>
<td><input id="cnum" name="cnum" type="password" size="54" /></td>
</tr>
<tr>
<td><label for="pnum">Phone Number:</label></td>
<td><input id="pnum" name="pnum" type="text" size="53" /></td>
</tr>
</tr>
</table>
</fieldset>
<img id="modelimg" src="milleniumcomputergo.png" alt="Millenium Computer" />
<p id="model">One of our hand-constructed laptops</p>
</td>
</tr>
<!-- Buttons -->
<tr>
<td>
<table>
<tr>
<td align="center">
onclick="calculatePrice">Submit Order</button>--%>
<asp:Button ID="btnSubmit" runat="server" Text="Submit Order" onclick="btnSubmit_Click"/>
</td>
<td align="left">
<button id="cancel" name="cancel" type="reset" value="cancel">Cancel</button>
</td>
</tr>
</table>
</td>
</tr>
</asp:Panel>
</form>
</body>
</html>
and my cs page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class pc : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
frmMillenium.Visible = false;
int total;
}
}
so again, my objective is to add all the selected values of the user (ex all the radio buttons and drop down list selections selected) and add them together and display the total. Any help would be greatly appreciated, Thanks!
in the .cs or code behind page, you can reference the values for the controls on your page by simply referencing the control id name and the appropriate property.
If your using any of the Visual Studio development platform, it should automatically (using intellisense) show you the methods and properties of the control you're referencing.
Example from your code (Note..crude sample below and this is free hand so errors may abound...)
//Sum costs (note: change your total data type to double)
total = 0;
double memCost;
if(Double.TryParse(mem.SelectedItem.Text.SubString(mem.SelectedItem.Text.IndexOf("$")+1), out memCost) { total += memCost; }
//add a value property to the dvd (and othercheckboxes) with the dollar amount and do the following
if(dvd.checked){ total += dvd.value; }
//rinse and repeat...
//Display results
string Summary = string.Empty;
if(mem.SelectedItem.Text != string.Empty){ Summary = Summary + mem.SelectedItem.Text + "<br />"; }
//rinse and repeat
//Add a littleral control to your form and assign the "Text" property the Summary variable above
Hope this helps get you started...
Dave
Related
So previously my login worked fine. And then I made some edits and it stopped working. Here are the edits I made to my website in between it going from working to not working.
I was trying to make a submit content page but I kept getting errors about not being able to contain a form inside a form. So I went over to my master page and removed the form tag and then added all the form tags I needed into each individual page. In the end I ended up removing all form tags and putting a single form tag around the content place holder in the master page.
I added a new table to my SQL database to store content submitted by users. I use Microsoft Server Express for my database.
The error I am getting is not an error in my console, it is just that my PostBackURL is loaded with out anything happen. Even if I enter a correct login (I have checked and the login info I tested is stored in my database), it will just automatically load the PostBackURL with no login occuring, nor any Login failed messages.
Web Config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<authentication mode="Forms">
<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH">
</forms>
</authentication>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
Master Page (Relevant Parts):
<body>
<form id="form1" runat="server">
<div class="header headerLogin">
<img style="margin-left: 5vw; margin-top: 5px; height: 32px; width: 130px;" src="images/inshortlogo.png" />
<p class="taskbarLinks">
HOME
NEWS
JOB LISTINGS
STUDY
LOGIN
</p>
<script>
...
</script>
</div>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
Login Page:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="Absolute-Center">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="Login1" runat="server">
<LayoutTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0">
<tr>
<td align="center" colspan="2">Log In</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="ctl08$Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="ctl08$Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" CssClass="button" PostBackUrl="~/home.aspx" Text="Log In" ValidationGroup="ctl08$Login1" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
<br />
<div style="text-align: center;">
<a class="button" style="margin-right: 2em;" href="signup.aspx">Register</a>
<a class="button" href="forgotpassword.aspx">Forgot Password</a>
</div>
</AnonymousTemplate>
<LoggedInTemplate>
<asp:Label ID="logOutLabel" runat="server" Text=""></asp:Label>
<br />
<br />
<div style="text-align: center;">
<asp:LinkButton ID="logOutButton" runat="server" class="button" OnClick="logOutButton_Click">Log Out</asp:LinkButton>
</div>
</LoggedInTemplate>
</asp:LoginView>
</div>
<style>
.Absolute-Center {
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
</style>
</asp:Content>
Thanks in advance!
Remove the postbackurl. That posts the form to another page, so of course you don't get logged in. Instead, upon successful login, perform a redirect to whatever page you want.
I have a radio button like below, and i am unable to delete the border of that radio button in IE. The same is working in Chrome.
<fieldset id="fsdeSign">
<table width="98%">
<tr>
<td align="right" colspan="2">
<div id="divName" runat="server" visible="false">
<span>
<label class="required" runat="server" id="Label1" style="width: 90px">
<span id="NameSpan" runat="server">*</span>Name</label></span>
<asp:TextBox ID="textName" runat="server" MaxLength="20"></asp:TextBox>
</div>
</td>
<td align="right">
<asp:Label ID="lblaccount" Style="display: none" runat="server" Width="155px"
Text="Would you like to use your account?"></asp:Label>
</td>
<td align="left">
<asp:RadioButtonList ID="rblaccount" runat="server" Style="display: none;border-style:none;" RepeatDirection="Horizontal">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" Text="No" Selected="True" />
</asp:RadioButtonList>
</td>
</tr>
</table>
</fieldset>
I have used the below cssclass="Sign" which is not reflecting.Do i need add any more tags?
fieldset#fseSign input.Sign
{
border-style:none;
}
Try to add BorderStyle="None" within <asp: RadioButtonList>. Your code should look like this:
<asp:RadioButtonList ID="rblaccount" runat="server" Style="display: none" RepeatDirection="Horizontal" BorderStyle="None">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" Text="No" Selected="True" />
</asp:RadioButtonList>
In any case, try to have a look at this similar case here.
In case it does not work, it is also possible that you have to edit its css in the following way:
input[type="radio"] {
border-style:none;
}
Try this fieldset#fsdeSign input
{border-style: none;}
I am having lot of space between newly added radiobuttons(yes and No) of the RadioButtonList and the first part of the existing region(divName) is aligned properly.
can any body help me in aligning the newly added second region(div1)
<div id="divpanelFacts" runat="server">
<fieldset id="panelFacts">
<table width="100%">
<tr>
<td>
<div id="divName" runat="server" visible="false">
<span>
<label runat="server" id="Label1">
<span id="pNameSpan" runat="server">*</span>P Name</label>
<asp:TextBox ID="textPName" runat="server" MaxLength="20"></asp:TextBox>
</span>
</div>
</td>
<td>
<div id="div1" runat="server" visible="false">
<asp:Label ID="lbl1" runat="server" Text="Would like to use this option for document purpose"></asp:Label>
<asp:RadioButtonList ID="rbl1" runat="server" TextAlign="Left" RepeatDirection="Horizontal">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" Text="No" Selected="True" />
</asp:RadioButtonList>
</div>
</td>
</tr>
</table>
</fieldset>
</div>
Your table width is at 100%, which means it's going to stretch it, and table I think takes precedence.
This is my code:
<h:panelGroup id="deliveryAddress" columns="2">
<h:selectOneRadio id="deliveryAddressRadioGroup" value="#{mybean.deliveryAddress}" layout="pageDirection" onclick="resetTextField()">
<f:selectItem id="pickedUp" itemValue="wird abgeholt (WET B4)" itemLabel="#{msg.subscriptionFormFieldDeliveryAddressPickedUp}"/>
<f:selectItem id="send2OrderingPerson" itemValue="Versand an Bestellenden" itemLabel="#{msg.subscriptionFormFieldDeliveryAddressSend2OrderingPerson}"/>
<f:selectItem id="send2SubscrOwner" itemValue="Versand an Abonnementsbesitzer" itemLabel="#{msg.subscriptionFormFieldDeliveryAddressSend2SubscrOwner}"/>
<f:selectItem id="send2SupportGroup" itemValue="Versand an Support-Gruppe" itemLabel="#{msg.subscriptionFormFieldDeliveryAddressSend2SupportGroup}"/>
</h:selectOneRadio>
</h:panelGroup>
From that I expect that the ids of the single buttons are pickedUp, send2OrderingPerson, send2SubscrOwner and send2SupportGroup. (or at least detailForm:xxx).
Instead, if I look at the resulting code, I get:
<span id="detailForm:deliveryAddress">
<table id="detailForm:deliveryAddressRadioGroup">
<tbody>
<tr>
<td>
<input id="detailForm:deliveryAddressRadioGroup:0" type="radio" onclick="resetTextField()" value="wird abgeholt (WET B4)" name="detailForm:deliveryAddressRadioGroup">
<label for="detailForm:deliveryAddressRadioGroup:0"> will be piched up (WET B4)</label>
</td>
</tr>
<tr>
<td>
<input id="detailForm:deliveryAddressRadioGroup:1" type="radio" onclick="resetTextField()" value="Versand an Bestellenden" name="detailForm:deliveryAddressRadioGroup">
<label for="detailForm:deliveryAddressRadioGroup:1"> send to ordering person</label>
</td>
</tr>
<tr>
<td>
<input id="detailForm:deliveryAddressRadioGroup:2" type="radio" onclick="resetTextField()" value="Versand an Abonnementsbesitzer" name="detailForm:deliveryAddressRadioGroup" checked="checked">
<label for="detailForm:deliveryAddressRadioGroup:2"> send to subscription's owner</label>
</td>
</tr>
<tr>
<td>
<input id="detailForm:deliveryAddressRadioGroup:3" type="radio" onclick="resetTextField()" value="Versand an Support-Gruppe" name="detailForm:deliveryAddressRadioGroup">
<label for="detailForm:deliveryAddressRadioGroup:3"> send to support group</label>
</td>
</tr>
</tbody>
</table>
</span>
What's wrong?
I am working to get a HTML File Upload control in place in a ASPX Web Form page. I have used the below code
<td class="ClientDetailTableLeftColumn">
<asp:Label ID="lblUpload" runat="server" Text="Upload File"></asp:Label>
</td>
<td "ClientDetailTableControls" colspan="2">
<p id="UploadArea">
<input id="FileUploadInput" type="file" size="20"/>
<asp:Button ID="btnUpload" runat="server" Text="Click To Upload" CssClass="btnFormSubmit" />
</p>
<input id="btnUploadMore" type="button" value="Add New Attachment" onclick="AddUploadBox" />
</td>
But while running in Local IIS I am getting an error.
System.Web.UI.HtmlControls.HtmlTableCellCollection must have items of
type System.Web.UI.HtmlControls.HtmlTableCell'. 'p' is of type
System.Web.UI.HtmlControls.HtmlGenericControl'.
The code is failing in the 2nd Line :
Line 85: <td "ClientDetailTableControls" colspan="2">
Line 86: <p id="UploadArea">
Can somebody please help me what could be the resolution to this? Or why is this failing?
Try this
<td class="ClientDetailTableLeftColumn">
<asp:Label ID="lblUpload" runat="server" Text="Upload File"></asp:Label>
</td>
<td "ClientDetailTableControls" colspan="2">
<div id="UploadArea">
<input id="FileUploadInput" type="file" size="20"/>
<asp:Button ID="btnUpload" runat="server" Text="Click To Upload" CssClass="btnFormSubmit" />
</div>
<input id="btnUploadMore" type="button" value="Add New Attachment" onclick="AddUploadBox" />
</td>