View Single Post
  #8 (permalink)  
Old March 30th, 2009, 05:35 AM
areed24 areed24 is offline
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, is this better:

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></tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Code Behind Page
Code:
Protected Sub radio1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radio1.SelectedIndexChanged
If Page.IsValid Then
If radio1.SelectedItem.ToString = "Dollars" Then
Dim result As Single = 0
Dim crate As Single = 0.7836
Dim currency As Single = 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 As Single = 0
Dim crate As Single = 1.2762
Dim currency As Single = Convert.ToSingle(txtcurrency.Text)
result = currency * crate
lblcurrencyResult.Text = "$ " & System.Math.Round(Convert.ToDecimal(result), 2)
Else
lblcurrencyResult.Text = ""
End If
End If
End Sub