View Single Post
  #5 (permalink)  
Old March 27th, 2009, 01:04 PM
areed24 areed24 is offline
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
<asp:ContentID="Content2"ContentPlaceHolderID="cpMainContent"Runat="Server">
<asp:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<tablewidth="100%">
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">Value</td>
<tdclass="style2">Unit of Measurement</td>
<td>Converted Value</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
Currency</td>
<tdclass="style4">
<asp:TextBoxID="txtcurrency"runat="server"AutoPostBack="True"CausesValidation="True"Width="49px"style="margin-left: 0px"></asp:TextBox>
</td>
<tdclass="style2">
<asp:radiobuttonlistid="radio1"runat="server"AutoPostBack="True"CausesValidation="True">
<asp:listitemid="option1"runat="server"value="Dollars"/>
<asp:listitemid="option2"runat="server"value="Euros"/>
</asp:radiobuttonlist></td>
<td><asp:LabelID="lblcurrencyResult"runat="server"></asp:Label></td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style1"colspan="2">
<asp:RangeValidatorID="RangeValidator1"runat="server"ControlToValidate="txtcurrency"ErrorMessage="Please enter a valid number"MaximumValue="1000000"MinimumValue="0"Type="Double"></asp:RangeValidator>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">&nbsp;</td>
<tdclass="style2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
Temperature</td>
<tdclass="style4">
<asp:TextBoxID="txttemp"runat="server"AutoPostBack="True"CausesValidation="True"Width="49px"></asp:TextBox>
</td>
<tdclass="style2">
<asp:RadioButtonListID="radio2"runat="server"AutoPostBack="True">
<asp:ListItemID="option3"runat="server"value="&deg Fahrenheit"/>
<asp:ListItemID="option4"runat="server"value="&deg Celcius"/>
</asp:RadioButtonList>
</td>
<td>
<asp:LabelID="lbltempResult"runat="server"></asp:Label>
</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">
<asp:RangeValidatorID="RangeValidator2"runat="server"ControlToValidate="txttemp"ErrorMessage="Please enter a valid number"MaximumValue="1000"MinimumValue="0"Type="Double"></asp:RangeValidator>
</td>
<tdclass="style2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">&nbsp;</td>
<tdclass="style2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
Weight</td>
<tdclass="style4">
<asp:TextBoxID="txtweight"runat="server"AutoPostBack="True"CausesValidation="True"Width="49px"></asp:TextBox>
</td>
<tdclass="style2">
<asp:RadioButtonListID="radio3"runat="server"AutoPostBack="True">
<asp:ListItemID="option5"runat="server"value="Pounds"/>
<asp:ListItemID="option6"runat="server"value="Kilos"/>
</asp:RadioButtonList>
</td>
<td>
<asp:LabelID="lblweightResult"runat="server"></asp:Label>
</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">
<asp:RangeValidatorID="RangeValidator3"runat="server"ControlToValidate="txtweight"ErrorMessage="Please enter a valid number"MaximumValue="1000"MinimumValue="0"Type="Double"></asp:RangeValidator>
</td>
<tdclass="style2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">&nbsp;</td>
<tdclass="style2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
Height</td>
<tdclass="style4">
<asp:TextBoxID="txtheight"runat="server"AutoPostBack="True"CausesValidation="True"Width="49px"></asp:TextBox>
</td>
<tdclass="style2">
<asp:RadioButtonListID="radio4"runat="server"AutoPostBack="True">
<asp:ListItemID="option7"runat="server"value="Inches"/>
<asp:ListItemID="option8"runat="server"value="Meters"/>
</asp:RadioButtonList>
</td>
<td>
<asp:LabelID="lblheightResult"runat="server"></asp:Label>
</td>
</tr>
<tr>
<tdclass="style5">&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">
<asp:RangeValidatorID="RangeValidator4"runat="server"ControlToValidate="txtheight"ErrorMessage="Please enter a valid number"MaximumValue="1000"MinimumValue="0"Type="Double"></asp:RangeValidator>
</td>
<tdclass="style2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdclass="style5">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">
&nbsp;</td>
<tdclass="style2">
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<tdclass="style5">
&nbsp;</td>
<tdclass="style3">
Distance</td>
<tdclass="style4">
<asp:TextBoxID="txtdistance"runat="server"AutoPostBack="True"CausesValidation="True"Width="49px"></asp:TextBox>
</td>
<tdclass="style2">
<asp:RadioButtonListID="radio5"runat="server"AutoPostBack="True">
<asp:ListItemID="option9"runat="server"value="Miles"/>
<asp:ListItemID="option10"runat="server"value="Kilometers"/>
</asp:RadioButtonList>
</td>
<td>
<asp:LabelID="lbldistanceResult"runat="server"></asp:Label>
</td>
</tr>
<tr>
<tdclass="style5">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">
<asp:RangeValidatorID="RangeValidator5"runat="server"ControlToValidate="txtdistance"ErrorMessage="Please enter a valid number"MaximumValue="1000"MinimumValue="0"Type="Double"></asp:RangeValidator>
</td>
<tdclass="style2">
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<tdclass="style5">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">
&nbsp;</td>
<tdclass="style2">
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<tdclass="style5">
&nbsp;</td>
<tdclass="style3">
Cooking</td>
<tdclass="style4">
<asp:TextBoxID="txtcooking"runat="server"AutoPostBack="True"CausesValidation="True"Width="49px"></asp:TextBox>
</td>
<tdclass="style2">
<asp:RadioButtonListID="radio6"runat="server"AutoPostBack="True">
<asp:ListItemID="option11"runat="server"value="Cups"/>
<asp:ListItemID="option12"runat="server"value="Milliliters"/>
</asp:RadioButtonList>
</td>
<td>
<asp:LabelID="lblcookingResult"runat="server"></asp:Label>
</td>
</tr>
<tr>
<tdclass="style5">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style4">
<asp:RangeValidatorID="RangeValidator6"runat="server"ControlToValidate="txtcooking"ErrorMessage="Please enter a valid number"MaximumValue="1000"MinimumValue="0"Type="Double"></asp:RangeValidator>
</td>
<tdclass="style2">
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>


Page behind:
Code:
ProtectedSub radio1_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles radio1.SelectedIndexChanged
If Page.IsValid Then
If radio1.SelectedItem.ToString = "Dollars"Then
Dim result AsSingle = 0
Dim crate AsSingle = 0.7836
Dim currency AsSingle = Convert.ToSingle(txtcurrency.Text)
result = currency * crate
lblcurrencyResult.Text = System.Math.Round(Convert.ToDecimal(result), 2) & " &euro;"
ElseIf radio1.SelectedItem.ToString = "Euros"Then
Dim result AsSingle = 0
Dim crate AsSingle = 1.2762
Dim currency AsSingle = Convert.ToSingle(txtcurrency.Text)
result = currency * crate
lblcurrencyResult.Text = "$ " & System.Math.Round(Convert.ToDecimal(result), 2)
Else
lblcurrencyResult.Text = ""
EndIf
EndIf
EndSub
ProtectedSub radio2_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles radio2.SelectedIndexChanged
If Page.IsValid Then
If radio2.SelectedItem.ToString = "&deg Fahrenheit"Then
Dim result AsSingle = 0
Dim temp AsSingle = Convert.ToSingle(txttemp.Text)
result = (temp - 32) * 5 / 9
lbltempResult.Text = System.Math.Round(result) & " &deg Celcius"
ElseIf Page.IsValid AndAlso radio2.SelectedItem.ToString = "&deg Celcius"Then
Dim result AsSingle = 0
Dim temp AsSingle = Convert.ToSingle(txttemp.Text)
result = (temp * 9 / 5) + 32
lbltempResult.Text = System.Math.Round(result) & " &deg Fahrenheit"
Else
lbltempResult.Text = ""
EndIf
EndIf
EndSub
ProtectedSub radio3_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles radio3.SelectedIndexChanged
If Page.IsValid Then
If radio3.SelectedItem.ToString = "Pounds"Then
Dim result AsSingle = 0
Dim weight AsSingle = Convert.ToSingle(txtweight.Text)
result = weight * (0.45359)
lblweightResult.Text = System.Math.Round(result, 1) & " Kilos"
ElseIf Page.IsValid AndAlso radio3.SelectedItem.ToString = "Kilos"Then
Dim result AsSingle = 0
Dim weight AsSingle = Convert.ToSingle(txtweight.Text)
result = weight * 2.2046
lblweightResult.Text = System.Math.Round(result, 1) & " Pounds"
Else
lblweightResult.Text = ""
EndIf
EndIf
EndSub
ProtectedSub radio4_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles radio4.SelectedIndexChanged
If Page.IsValid Then
If radio4.SelectedItem.ToString = "Inches"Then
Dim result AsSingle = 0
Dim height AsSingle = Convert.ToSingle(txtheight.Text)
result = height * 0.0254
lblheightResult.Text = System.Math.Round(result, 2) & " Meters"
ElseIf Page.IsValid AndAlso radio4.SelectedItem.ToString = "Meters"Then
Dim result AsSingle = 0
Dim height AsSingle = Convert.ToSingle(txtheight.Text)
result = height * 39.37
lblheightResult.Text = System.Math.Round(result, 1) & " Inches"
Else
lblheightResult.Text = ""
EndIf
EndIf
EndSub
ProtectedSub radio5_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles radio5.SelectedIndexChanged
If Page.IsValid Then
If radio5.SelectedItem.ToString = "Miles"Then
Dim result AsSingle = 0
Dim distance AsSingle = Convert.ToSingle(txtdistance.Text)
result = distance * 1.60934
lbldistanceResult.Text = System.Math.Round(result, 2) & " Kilometers"
ElseIf Page.IsValid AndAlso radio5.SelectedItem.ToString = "Kilometers"Then
Dim result AsSingle = 0
Dim distance AsSingle = Convert.ToSingle(txtdistance.Text)
result = distance * 0.62
lbldistanceResult.Text = System.Math.Round(result, 2) & " Miles"
Else
lbldistanceResult.Text = ""
EndIf
EndIf
EndSub
ProtectedSub radio6_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles radio6.SelectedIndexChanged
If Page.IsValid Then
If radio6.SelectedItem.ToString = "Cups"Then
Dim result AsSingle = 0
Dim cooking AsSingle = Convert.ToSingle(txtcooking.Text)
result = cooking * 236.5882
lblcookingResult.Text = System.Math.Round(result, 2) & " Milliliters"
ElseIf Page.IsValid AndAlso radio6.SelectedItem.ToString = "Milliliters"Then
Dim result AsSingle = 0
Dim cooking AsSingle = Convert.ToSingle(txtcooking.Text)
result = cooking * 0.00423675
lblcookingResult.Text = System.Math.Round(result, 3) & " Cups"
Else
lblcookingResult.Text = ""
EndIf
EndIf
EndSub
EndClass