Hi all
I am developing an application in vb.net that allows a user to select a number of items via checkboxes, dropdown lists etc.
The results page needs to show the items selected by the user and the value for that selection in a table.
I can get all the items to show and if selected their value, but i need to be able to hide the name of the item selected and its value if it is not selected by the user.
Could someone please advise me how to do this?
Thanks in advance
Kevin
Code looks like this so far:
Input page
<tr>
<td>
Bathroom with W/C:</td>
<td>
<asp:CheckBox id="bathroom_with_wc" runat="server"></asp:CheckBox>
</td>
</tr>
<tr>
<td>
Separate Bathroom:</td>
<td>
<asp:CheckBox id="seperate_bathroom" runat="server"></asp:CheckBox>
</td>
</tr>
</tbody>
</table>
<p>
<asp:button id="calculatebutton" onclick="calculate" runat="server" text="calculate"></asp:button>
<asp:button id="resetbutton" runat="server" text="Reset"></asp:button>
Codebehind
' SimpleRent.vb
'
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace nihe
Public Class SimpleRent : inherits page
Public rentcalcSum as Integer
Public weeklyrent as double
Public rentpointvalue as double = 130.4
protected withevents bathroom_with_wc As system.web.ui.webcontrols.checkbox
protected withevents seperate_bathroom As system.web.ui.webcontrols.checkbox
protected withevents resetbutton As system.web.ui.webcontrols.button
protected withevents row_bathroom_with_wc As system.web.ui.webcontrols.TableRow
protected withevents row_seperate_bathroom As system.web.ui.webcontrols.TableRow
sub Page_Load
resetbutton.Attributes.Add(”onclick”, “JavaScript:document.forms[0].reset(); return false;“)
end sub
Public sub calculate(source as Object, e as EventArgs)
'process for collecting checkbox values
if bathroom_with_wc.checked then
rentcalcsum = rentcalcsum + 3
bathroom_with_wc.text = "+3"
Context.Items.Add("bathroom_with_wc", bathroom_with_wc.text)
row_bathroom_with_wc.Visible = bathroom_with_wc.checked
end if
if seperate_bathroom.checked then
rentcalcsum = rentcalcsum + 2
seperate_bathroom.text = "+2"
Context.Items.Add("seperate_bathroom", seperate_bathroom.text)
row_seperate_bathroom.Visible = seperate_bathroom.checked
end if
weeklyrent = rentcalcsum * rentpointvalue
weeklyrent = weeklyrent / 100
weeklyrent = Math.Round(weeklyrent, 2)
Context.Items.Add("weeklyrent", weeklyrent)
server.transfer("SimpleResult.aspx")
End Sub
End Class
End Namespace
Results page
<%@ Page Language="vb" %>
<script runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
label1.text = "The weekly rent on this property would be £" & Context.Items("weeklyrent")
cell_bathroom_with_wc.text = "Bathroom with WC"
value_bathroom_with_wc.text = Context.Items("bathroom_with_wc")
cell_seperate_bathroom.text = "Seperate Bathroom"
value_seperate_bathroom.text = Context.Items("seperate_bathroom")
'
End Sub
</script>
<html>
<head>
<title>Rent Result Page</title>
</head>
<body>
<h3>Rent Calculator</h3>
<asp:Label id="label1" runat="server"></asp:Label>
<br />
<form>
<asp:Table borderwith="1" runat="server">
<asp:TableRow id="row_bathroom_with_wc" visible="false">
<asp:TableCell id="cell_bathroom_with_wc"></asp:TableCell>
<asp:TableCell id ="value_bathroom_with_wc"></asp:TableCell>
</asp:TableRow>
<asp:TableRow id="row_seperate_bathroom" visible="false">
<asp:TableCell id="cell_seperate_bathroom"></asp:TableCell>
<asp:TableCell id="value_seperate_bathroom"></asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>
I am developing an application in vb.net that allows a user to select a number of items via checkboxes, dropdown lists etc.
The results page needs to show the items selected by the user and the value for that selection in a table.
I can get all the items to show and if selected their value, but i need to be able to hide the name of the item selected and its value if it is not selected by the user.
Could someone please advise me how to do this?
Thanks in advance
Kevin
Code looks like this so far:
Input page
<tr>
<td>
Bathroom with W/C:</td>
<td>
<asp:CheckBox id="bathroom_with_wc" runat="server"></asp:CheckBox>
</td>
</tr>
<tr>
<td>
Separate Bathroom:</td>
<td>
<asp:CheckBox id="seperate_bathroom" runat="server"></asp:CheckBox>
</td>
</tr>
</tbody>
</table>
<p>
<asp:button id="calculatebutton" onclick="calculate" runat="server" text="calculate"></asp:button>
<asp:button id="resetbutton" runat="server" text="Reset"></asp:button>
Codebehind
' SimpleRent.vb
'
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace nihe
Public Class SimpleRent : inherits page
Public rentcalcSum as Integer
Public weeklyrent as double
Public rentpointvalue as double = 130.4
protected withevents bathroom_with_wc As system.web.ui.webcontrols.checkbox
protected withevents seperate_bathroom As system.web.ui.webcontrols.checkbox
protected withevents resetbutton As system.web.ui.webcontrols.button
protected withevents row_bathroom_with_wc As system.web.ui.webcontrols.TableRow
protected withevents row_seperate_bathroom As system.web.ui.webcontrols.TableRow
sub Page_Load
resetbutton.Attributes.Add(”onclick”, “JavaScript:document.forms[0].reset(); return false;“)
end sub
Public sub calculate(source as Object, e as EventArgs)
'process for collecting checkbox values
if bathroom_with_wc.checked then
rentcalcsum = rentcalcsum + 3
bathroom_with_wc.text = "+3"
Context.Items.Add("bathroom_with_wc", bathroom_with_wc.text)
row_bathroom_with_wc.Visible = bathroom_with_wc.checked
end if
if seperate_bathroom.checked then
rentcalcsum = rentcalcsum + 2
seperate_bathroom.text = "+2"
Context.Items.Add("seperate_bathroom", seperate_bathroom.text)
row_seperate_bathroom.Visible = seperate_bathroom.checked
end if
weeklyrent = rentcalcsum * rentpointvalue
weeklyrent = weeklyrent / 100
weeklyrent = Math.Round(weeklyrent, 2)
Context.Items.Add("weeklyrent", weeklyrent)
server.transfer("SimpleResult.aspx")
End Sub
End Class
End Namespace
Results page
<%@ Page Language="vb" %>
<script runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
label1.text = "The weekly rent on this property would be £" & Context.Items("weeklyrent")
cell_bathroom_with_wc.text = "Bathroom with WC"
value_bathroom_with_wc.text = Context.Items("bathroom_with_wc")
cell_seperate_bathroom.text = "Seperate Bathroom"
value_seperate_bathroom.text = Context.Items("seperate_bathroom")
'
End Sub
</script>
<html>
<head>
<title>Rent Result Page</title>
</head>
<body>
<h3>Rent Calculator</h3>
<asp:Label id="label1" runat="server"></asp:Label>
<br />
<form>
<asp:Table borderwith="1" runat="server">
<asp:TableRow id="row_bathroom_with_wc" visible="false">
<asp:TableCell id="cell_bathroom_with_wc"></asp:TableCell>
<asp:TableCell id ="value_bathroom_with_wc"></asp:TableCell>
</asp:TableRow>
<asp:TableRow id="row_seperate_bathroom" visible="false">
<asp:TableCell id="cell_seperate_bathroom"></asp:TableCell>
<asp:TableCell id="value_seperate_bathroom"></asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>