Viewing source for recipe0113cs.aspx

<%@ Page %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>recipe0113cs</title>
		<script language="C#" runat="server">

    public void Page_Load(Object sender, EventArgs e) {

			// emit script to set initial focus		   
			RegisterStartupScript("focus",
				"<SCRIPT language='javascript'>" +
				"form1.UserNameTextBox.focus()" +
				"</" + "SCRIPT>" );

			// emit script to check for blank password
			RegisterClientScriptBlock("myscripts",
				"<SCRIPT language='javascript'>" +
				"function checkPwd(){" +
				" if ( form1.PasswordTextBox.value == '')" +
				"  if ( confirm('Are you sure about a blank password?'))" +
				"   return true;" +
				"  else {" +
				"   form1.PasswordTextBox.focus();" +
				"   return false;" +
				"  } else return true;" +
				" } </" + "SCRIPT>" );
			
			// emit script in submit button attributes to call checkPwd function
			SubmitButton.Attributes.Add("OnClick","javascript:return checkPwd()");

			if ( IsPostBack )
				ResultLabel.Text = String.Format("User='{0}', Password='{1}'",
					UserNameTextBox.Text, PasswordTextBox.Text );
			else ResultLabel.Text = "";
		}
		</script>
	</HEAD>
	<BODY>
		<form id="form1" method="post" runat="server">
			<asp:TextBox id="UserNameTextBox" runat="server"></asp:TextBox>
			<br>
			<asp:TextBox id="PasswordTextBox" runat="server" TextMode="Password"></asp:TextBox>
			<br>
			<asp:Button id="SubmitButton" runat="server" Text="Submit"></asp:Button>
			<br>
			<br>
			<asp:Label id="ResultLabel" runat="server">Label</asp:Label>
		</form>
	</BODY>
</HTML>