PART 1
CHAPTER 1
Chapter 1 Note 4
Part 1 5
Chapter 1 AcctNum = Table ("Customer").Cells("AccountNumber") AcctNum = Customer.AccountNumber Note 6
RecordSet RecordSet Part 1 Note 7
Chapter 1 01: <html> 02: <head> 03: <title>programming Datadriven Web Applications with ASP.NET -Chapter 1</title> 04: </head> 05: <body> 06: <% 07: Dim strname,strprefix 08: strname = Request.Form("txtName" ) 09: strprefix = Request.Form("selPrefix" ) 10: 11: If Request.Form.Count >0 Then 12: If Not Trim(strName)=" " Then 13: %> 14: Hello <%=strprefix%> <%=strname%><br> 15: <%Else%> 16: Please enter your name. 17: <%End If%> 18: <%End If%> 19: 20: <form method="post" action="0101.asp" > 21: Name: <br> 22: <input type="text" name="txtname" value="<%=strname%>"><br> 23: 24: Prefix: <br> 25: <select name="selprefix" > 26: <option>--select One--</option> 27: <option <%If strprefix ="Mr." Then%>selected<%End If%>>Mr.</option> 28: <option <%If strprefix ="Ms." Then%>selected<%End If%>>Ms.</option> 29: <option <%If strprefix ="Mrs." Then%>selected<%End If%>>Mrs.</option> 30: </select> 31: <p><input type="submit" value="submit" ></p> 32: </form> 33: </body> 34: </html> 8
If...Then If...Then txtname txtname [VB ] 01: <script runat="server" language="vb" > 02: Protected Sub Page_Load(Sender As Object, E As EventArgs) 03: If Page.IsPostBack And Page.IsValid Then 04: Welcome.Text ="Hello" &selprefix.value & " "& txtname.text & <br><br> 05: End If 06: End Sub 07: </script> Part 1 [C#] 01: <script runat="server" language=="c#"> 02: protected void Page_Load(object sender, EventArgs e){ 03: if(page.ispostback && Page.IsValid){ 04: Welcome.Text ="Hello" +selprefix.value + " "+ txtname.text +"<br><br>"; 05: } 06: } 07: </script> [VB & C#] 08: <html> 09: <head> 10: <title>programming Datadriven Web Applications with ASP.NET -Chapter 1</title> 11: </head> 12: <body> 13: <form runat="server" method="post" > 9
Chapter 1 14: <asp: Label runat="server" id="welcome" /> 15: <asp: TextBox runat="server" id="txtname" /> 16: <asp: RequiredFieldValidator runat="server" 17: ControlToValidate="txtName" 18: ErrorMessage="Please enter your name." 19: ForeColor="#CC3300" /> 20: <br> 21: Prefix: <br> 22: <select id="selprefix" runat="server" > 23: <option>--select One--</option> 24: <option>mr.</option> 25: <option>ms.</option> 26: <option>mrs.</option> 27: </select> 28: <asp: RequiredFieldValidator runat="server" 29: ControlToValidate="selPrefix" 30: InitialValue="--Select One--" 31: ErrorMessage="Please select your prefix." 32: ForeColor="#CC3300" /> 33: <p><input type="submit" value="submit" runat="server" ></p> 34: </form> 35: </body> 36: </html> RequiredFieldValidator txtname TextBox TextBox RequiredFieldValidator <select>-</select> <select> RequiredFieldValidator 10
Part 1 11
Chapter 1 runat="server" runat="server" type="text" TextBoxID.BackColor= "blue" 12
<select> runat= "server" <select> Part 1 ViewState ViewState VIEWSTATE VIEWSTATE <select> ViewState VIEWSTATE 13
Chapter 1 01: <html> 02: <head> 03: <title>programming Datadriven Web Applications with ASP.NET - Chapter 1</title> 04: </head> 05: <body> 06: <form name="ctrl0" method="post" action="01.02.aspx" language="javascript" onsubmit="validatoronsubmit();" id="ctrl0"> 07: <input type="hidden" name=" VIEWSTATE" value="ddwtmtc0njqxmdyxmzt0pdtspgk8mt47pjtsphq8o2w8atwxpjs+o2w8ddxwpha 8bDxUZXh0Oz47bDxIZWxsbyBNci4gTWlsdG9uIFBhdmxvdlw8YnJcPlw8YnJcPjs +Pjs+Ozs+Oz4+Oz4+Oz4=" /> 08: 09: <script language="javascript" 10: src="/ aspnet_client/system_web/1_0_2914_16/webuivalidation.js"></script> 11: 12: 13: <span id="welcome">hello Mr. Milton Pavlov<br><br></span> 14: <input name="txtname" type="text" value="milton Pavlov" id="txtname" /> 15: <span id="ctrl1" controltovalidate="txtname" errormessage="please enter your name." evaluationfunction="requiredfieldvalidatorevaluateisvalid" initialvalue="" style="color: #CC3300;visibility: hidden;"> Please enter your name.</span> 16: <br> 17: Prefix: <br> 18: <select name="selprefix" id="selprefix"> 19: <option value="--select One--">--Select One--</option> 20: <option selected="selected" value="mr.">mr.</option> 21: <option value="ms.">ms.</option> 22: <option value="mrs.">mrs.</option> 23: </select> 24: <span id="ctrl2" controltovalidate="selprefix" errormessage="please select your prefix." evaluationfunction="requiredfieldvalidatorevaluateisvalid" initialvalue="--select One--" style="color: #CC3300;visibility: hidden;"> Please select your prefix.</span> 25: <p><input onclick="javascript: {if (typeof(page_clientvalidate) == 'function') {Page_ClientValidate();}} " name="ctrl3" type="submit" value="submit" /></p> 14
ViewState Part 1 <span> <input type="text"> Calendar 15
Chapter 1 [VB] 01: <script language="vb" runat="server"> 02: Protected Sub SayHello(Source As Object, E As EventArgs) 03: divhello.innerhtml = "Hello " & _ 04: selprefix.value & " " & _ 05: txtname.value 06: txtname.visible = False 07: selprefix.visible = False 08: submitbutton.visible = False 09: End Sub 10: </script> [C#] 01: <script language="c#" runat="server"> 02: protected void SayHello(object sender, EventArgs e){ 03: divhello.innerhtml = "Hello " + 04: selprefix.value + " " + 05: txtname.value; 06: txtname.visible = false; 07: selprefix.visible = false; 08: submitbutton.visible = false; 09: } 10: </script> [VB & C#] 11: <html> 12: <head> 13: <title>programming Datadriven Web Applications with ASP.NET - Chapter 1</title> 14: </head> 16
15: <body> 16: <div id="divhello" runat="server" /> 17: <form method="post" runat="server"> 18: <input type="text" id="txtname" runat="server" 19: Value="Please Enter Name" ><br> 20: <select id="selprefix" runat="server"> 21: <option>--prefix--</option> 22: <option>mr.</option> 23: <option>ms.</option> 24: <option>mrs.</option> 25: </select> 26: <p><input type="submit" value="submit" id="submitbutton" 27: OnServerClick="SayHello" runat="server"></p> 28: </form> 29: </body> 30: </html> Part 1 Note SayHello( ) <script> </script> <script> < %... %> <script> 17
Chapter 1 <div> InnerHtml Prefix Visible False Visible False 18
Part 1 19
Chapter 1 ViewState ViewState runat="server" 20
<%@ OutputCache Duration="30" %> Part 1 21
Chapter 1 22