You are on page 1of 2

<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.

vb" Inhe
rits="Validation._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or
g/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
sub check_operator(sender As Object, e As EventArgs)
compval.Operator=CType(list.SelectedIndex,ValidationCompareOperator)
compval.Validate()
end sub
</script>
<form id="Form1" runat="server">
<table border="0" bgcolor="#b0c4de">
<tr valign="top">
<td colspan="9"><h4>Compare two values</h4></td>
</tr>
<tr valign="top">
<td><asp:TextBox id="txt1" runat="server" /></td>
<td>
<asp:ListBox id="list" rows="1" OnSelectedIndexChanged="check_operator" run
at="server">
<asp:ListItem value="Equal" selected>=</asp:ListItem>
</asp:ListBox>
</td>
<td><asp:TextBox id="txt2" runat="server" /></td>
<td><asp:Button ID="Button1" Text="Validate" runat="server" /></td>
</tr>
</table>
<br />
<asp:CompareValidator
id="compval"
Display="dynamic"
ControlToValidate="txt1"
ControlToCompare="txt2"
ForeColor="red"
BackColor="yellow"
Type="String"
EnableClientScript="false"
Text="Validation Failed!"
runat="server" BorderStyle="Inset" />
</form>

NEW

<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function Button1_onclick() {
var num1 = parseInt(document.getElementById('TextBox1').value);
var num2 = parseInt(document.getElementById('TextBox2').value);
document.getElementById('TextBox3').value = num1 + num2;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="return Button1
_onclick()" />
<asp:TextBox ID="TextBox3" runat="server" ReadOnly="True"></asp:TextBox>
</div>
</form>
</body>
</html>

You might also like