⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aspnet03-01.htm

📁 tutorialssss.... for everybody!!!!!!!!!!!!!!!!!!!
💻 HTM
📖 第 1 页 / 共 5 页
字号:
XHTML tags, and a formatted Visual Basic date property to server output controls 
coded on the page.</p>
<div class="page" style="height: 200px;"><span id="Heading">
<h3>Script-Generated Page Output</h3></span><span id="Paragraph">
<p>Today, <span style="color: red;">Saturday, March 29, 2008</span>, this output 
is produced by a script that writes text characters, XHTML tags, and a Visual 
Basic date function to server output controls coded on the page. The date is 
always current and does not require page editing.</p></span></div>
<div class="figure"><b>Figure 3-2. </b>Page output produced by script.</div><pre class="divcode">&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;!DOCTYPE html 
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<span class="script">
&lt;SCRIPT Runat="Server"&gt;

Sub Page_Load
	
  Heading.Text   = "&lt;h3&gt;Script-Generated Page Output&lt;/h3&gt;"
  Paragraph.Text = "&lt;p&gt;Today, &lt;span style=""color:red""&gt;" &amp; _
                   Format(DateString, "Long Date") &amp; "&lt;/span&gt;, " &amp; _
                   "this output is produced by a script that writes " &amp; _
                   "text characters, XHTML tags, and a Visual Basic " &amp; _
                   "date function to server output controls coded on " &amp; _
                   "the page. The date is always current and does not " &amp; _
                   "require page editing.&lt;/p&gt;"

End Sub

&lt;/SCRIPT&gt;
</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;
  &lt;title&gt;Script-Generated Page Output&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form Runat="Server"&gt;

&lt;asp:Label id="Heading" Runat="Server"/&gt;
&lt;asp:Label id="Paragraph" Runat="Server"/&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<div class="listing"><b>Listing 3-2. </b>Page produced by script output.</div>
<p>Script-generated information must be targeted to server controls as output 
areas. In the above example, two <span class="code">&lt;asp:Label&gt;</span> 
controls serve this purpose. They are given <span class="code">id</span> 
identifications so that the script, coded here in the <span class="code">Page_Load</span> subprogram, can specify where to place its output. 
The script assigns a string of text characters and XHTML to the <span class="code">Text</span> property of the <span class="code">Heading</span> Label to 
display as the page heading; it assigns a combination of text, XHTML, and a 
server-generated date to the <span class="code">Paragraph</span> Label. Notice 
that no XHTML or text information is hard-coded in the body of the page. It is 
generated and written entirely by the script.</p>
<p>In this example, the string of text assigned to the output Label itself 
contains a quoted string. Notice in the first line of the assignment,</p><pre class="script">Paragraph.Text = "&lt;p&gt;Today, &lt;span style=""color:red""&gt;" &amp; _
</pre>
<p>that the embedded <span class="code">&lt;span&gt;</span> tag includes the style 
setting <span class="code">style=""color:red""</span> wherein the property setting 
is enclosed inside a <i>pair</i> of quotes. Any time quoted text appears inside 
a quoted string it is necessary to use pairs of quotes surrounding the inner 
string to differentiate from the single quotes surrounding the outer string.</p>
<p class="head2">Script-Processed Input Data</p>
<p>Web page information can be produced by inputting user data and using it to 
generate output for display through server output controls. The following 
example solicits user input through a TextBox control. When the button is 
clicked, a subprogram is called to perform a calculation based on the entered 
value. The calculation result, along with surrounding text and XHTML, are 
written to a Label output control.</p>
<div class="page" style="height: 200px;">
<h3>User-Supplied Page Input</h3>Enter your age: <input id="Age" size="5" name="Age"> <input value="Submit" name="ctl01" type="submit"> <span id="DogAge"></span></div>
<div class="figure"><b>Figure 3-3. </b>Page output produced from user input.</div><pre class="divcode">&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;!DOCTYPE html 
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<span class="script">
&lt;SCRIPT Runat="Server"&gt;

Sub Get_Dog_Years (Src As Object, Args As EventArgs)

  If Age.Text &lt;&gt; "" Then
    Dim DogYears As Integer
    DogYears = Age.Text * 7
    DogAge.Text = "Your age is &lt;b&gt;" &amp; DogYears &amp; "&lt;/b&gt; in dog years!"
  End If
	
End Sub

&lt;/SCRIPT&gt;
</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;
  &lt;title&gt;User-Supplied Page Input&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form Runat="Server"&gt;

&lt;h3&gt;User-Supplied Page Input&lt;/h3&gt;

Enter your age: 
&lt;asp:TextBox id="Age" Size="5" Runat="Server"/&gt;
&lt;asp:Button Text="Submit" OnClick="Get_Dog_Years" Runat="Server"/&gt;
&lt;asp:Label id="DogAge" Runat="Server"/&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<div class="listing"><b>Listing 3-3. </b>Code for page produced from user 
input.</div>
<p>For this example, three server controls are needed. An <span class="code">&lt;asp:TextBox&gt; </span>control is required as the user input 
area; an <span class="code">&lt;asp:Button&gt; </span>control calls a subprogram 
to produce page output; an <span class="code">&lt;asp:Label&gt;</span> control 
serves as the display target for script output. When the button is clicked, the 
value entered into the TextBox is multiplied by 7 and the result is surrounded 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -