You are on page 1of 25

!

" # $%
&'
($ ) # $# $
$ * +,- * + + # .
* + / # $# ) ) 0 $
$ * +,- * + * + 0 (
$ 0 + # - )
1 $ 0 # / 0
# 0 # /0 $ /# +

2 # ) $# # / (
) $ ) # $
# + # $ 3 04 + # $$
# $ # 5 $ 3 67 # # $ +
# 0 0 $ 1 / 0 #
# . / ( . # # +
$ ) + +( 0 # + //
/ 0# $ #
6 $ . # 8 /9 $ #
+ ) $ # . +
) # + ## / +

5 $* + $ $
6 0 ( /
&
# * + 5 $
' * + /+ (
: - $ # * +
- # +( # 5 $ * + $
;
< < $
= - / / +( #
> #3?7
# 0 $ + 6 0 ( /
@ 0 # /. 6 0 (# #

! " #
2 # A# 0 # 0 # $#
3 / 0 # $# 9
# $ /
& - ( / # #3 * +
# 5
# A 5

# A # # # 0
* +
$ ! " % & '

2 A # # 9
$ $## $ 0 . 0
# / 9
# $ / # $+ $## $
# # A # * + B
# 0 A # ## 0 $
* + / + /0 9# $ $+ -0 #
# 0 0 # # A # .
# / $ 3 # B# $$ 0#
/ # 0 8) # + 3 /
# # $ # $+ 0 $
, / A # 0 ) / /#
2 # + # / A
# $ ) 0 .
# * + /
( $## $ 0 $ ) + + A
# 0

# #
0 8) # A 0 0 $
$ + # # 0 # $# 8 +
+ /
! ) * #

# $ + # 0 3 3 0 /

C $ + #D
// CustomLabel.cs
using System;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace John.AspNet.CS.Controls
{
public class CustomLabel : WebControl
{
public virtual string Text
{
get
{
string str = (string)ViewState["Text"];
return (str == null) ? String.Empty : str;
}
set
{
ViewState["Text"] = value;
}
}

protected override void RenderContents(HtmlTextWriter


writer)
{
writer.WriteEncodedText(Text);
Style textStyle = new Style();
writer.Write("!");
string str2 = "This is a custom control";
string[] arr = str2.Split(new Char[] { ' ' });
textStyle.ForeColor = System.Drawing.Color.Brown;
textStyle.BackColor = System.Drawing.Color.White;
int i = 12;
foreach (string s in arr)
{
if (s.Trim() != "")
{
writer.WriteBreak();
textStyle.Font.Size = FontUnit.Point(i);
writer.EnterStyle(textStyle);
writer.Write(s);
}
i = i + 4;
}
}
}
}

,
# $# . $ + # 8) ! # . )
0 $ * + # 0 $ 0 * + #
$ * +,- * + * +
public class CustomLabel : WebControl
-0 # $# 0# $
) + $ # + . ($ . )
# 0 $ * + # ) # -0 # $
# $ ) + # + . #
$ E$ F /. ) # 0 $
$ * +,- * + # ) 0 $
$ * +,- 9 # 5 .
5 . @ #3 - . # ) 0 $
* + # # 3 $ 0 0
( 3
# - .
2 # + # $# ) 0 $ ( /# .
# @ . + . -$ / G ) ($ +
+
# $# ) 0 $ * + # . 0 $ 0
( /# # @ . + . -$ /

, 0
2 # $# ) 1 $ 0
* + # # 0 # .
+!# 0 G$ (* # G $ (* #
# $ 0 / / G H G H
) %$ 3
protected override void RenderContents(HtmlTextWriter
writer)
- / . # $# ) 0 $ * + #
/ /. )
1 $ + 1 $ 0
* + # # # B / -0
# $# ) 1 $ # .
9 / /# + 1
$ 0 * + #

, 1 , -
2 # $# . +!# 0 G $ (* #
G H ( * +5 $ / / 0 $ /# +
) + G$ (* #

, 2 , -
* # ($ 0 G $ (* #
# ( * + / 5 ($ . $+
+ #3 0 ( # # E F. # I J I/J
$
writer.WriteEncodedText(Text);
-0 ) 0 / ( $
Assume that x > 4
0 # / 0 / ( $ /
Assume that x &gt; 4
# / # # # # E. F C
* + / * # / # #
# G H # # * +
/

/
,
# $# * $ 0 G$ (* #
( $ * + /
writer.Write("!");

,
2 # $# $ 3 $ 0 $ 0
# - @ #3 . 5
5 K 0 ( . +!# 0 #
Style textStyle = new Style();
textStyle.ForeColor = System.Drawing.Color.Brown;
textStyle.BackColor = System.Drawing.Color.White;

, 2
2 # $# $ 0 G$ (*
# $ $ #0
writer.EnterStyle(textStyle);
( $ 0 G$ (* #
0 0 5 $ 3

.' #
2 # /9 $ + # $# #
) ( # # ) /
) $ /9 $ + #
$ $+ ) ) 0 # / 0 # $ -
($ /9 $ +

* #. #
* +# 0/0 0 # 0 ( * +
2 / 0($ / * +# 0/
# $# * + /. 3

3
0 # # $ #
# # #
namespace John.AspNet.CS.Controls
{
public class CustomLabel : WebControl

* # 0/0
& 1 / # #3 * + # - $
- - $ # * + 0/ 5
#3

0 8) # * +# 0/0 ++ 3 $ /
3 0 /
C* +# 0/D+ 0
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you
can use the
web admin tool to configure settings for your
application. Use
the Website->Asp.Net Configuration option in Visual
Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0
">
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert
debugging
symbols into the compiled page. Because this
affects performance, set this value to true
only
during development.
-->
<compilation debug="false"/>
<!--
The <authentication> section enables
configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables
configuration
of what to do if/when an unhandled error
occurs
during the execution of a request.
Specifically,
it enables developers to configure html error
pages
to be displayed in place of a error stack
trace.

<customErrors mode="RemoteOnly"
defaultRedirect="GenericErrorPage.htm">
<error statusCode="403"
redirect="NoAccess.htm"/>
<error statusCode="404"
redirect="FileNotFound.htm"/>
</customErrors>
-->
</system.web>
</configuration>

4
-0 0 $ # / * +# 0/0 . #
# 0 * +# 0/0 8) ! # + 0 /#
) 0 * +# 0/0 3 3
C* +# 0/D 0
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="aspSample"
namespace="John.AspNet.CS.Controls"></add>
</controls>
</pages>
</system.web>
</configuration>

0 / / 0( $ / 0(L $ L
$ # .
<add tagPrefix="aspSample"
namespace="John.AspNet.CS.Controls"></add>

) # # 0 / / * +# 0/
0 H 3 / 0(C $ D # 0
E# F # . # $ + # $ 0
E / F # . # $ + # $ 0
E $ +F #
<pages>
<controls>
<add tagPrefix="aspSample"
namespace="John.AspNet.CS.Controls"></add>
</controls>
</pages>

( # 0/ 0 / 0( 0 0
- ) ) 0 / 0($ /
#0 1 / # ) # * + /
# $#
- ($ 0 # #0 / 0(
* +# 0/0 . $ 1 / # ) # /
# $# . ) ) 0 . 0
<%@ Register TagPrefix="aspSample" Namespace="
John.AspNet.CS.Controls "%>
-0 0$ 1 / + ) 0
. # $+ + #0 $ 0

5
# $+ $ /* $+ + $ /.
0 $+ $# # $ 0 $ #
0 A # 1 # $# # $ 0
0 A # ) + ) 0

) / 1 / # ) # ( /.
# ) # #0 / 0(M $ # $ /
* +# 0/0 0 0 # $# +
$ / * + # 0 / # # +
#0 / 0($ / * +# 0/

$ # * - .
0 8) #0 / 0($ / * +# 0/0 .
# $ + # # )
E $ ; $ + MF% / * + -
($ # $# 6 0 ( /
* 0 # * + 6 0 ( /
3 3
C6 0 (D+ 0 # /
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >


<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

0 /# E )F # 0 6 0 ( /
) /

4
<aspSample:CustomLabel Text="Hello" ID="CustomLabel2"
runat="server" BackColor="Wheat" />

6 0 ( / 0 8) # /# 3
3
C6 0 (D 0 # /
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >


<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<aspSample:CustomLabel Text="Hello"
ID="CustomLabel2"
runat="server" BackColor="Wheat" />
</div>
</form>
</body>
</html>

0 .

& 1 / # #3 6 0 ( / (
# @

4
# # &'

4
&>
& . .

6 $ .
# # $ . # # 0 .
# $ / $ 6 0 +0 / $ * +
/
-0 ) ( / $+ 0 %. # $ * +
$ # 0 # +
- ($
& # $ . # 0
, A # * +
# 9# $
' $ # $+ 6 0 %
: 6 0 * + )
0 # $ #
, 6 0 * + /
2 8 ) # $ +
$ 0 # 2 # # # $ / (
+ $0 $ # $$ / # $
5 $ 3 67
#
N
O # * + 5 $
& * + /+ (
&& - $ # * +
& - # +( # 5 $ * + $
;
< < $
&' - / / +( #
&: #3?7

3
& . .

# 0 $ + 6 0 ( /
@ 0 # /. 6 0 (# #

# #
& 1 / # #3 $ 0 * + (
# 5 M A 5
A 0 #

1 / # #3 A 0 ( #
- $
' # $
: ) # $ +( $ 0 # $
0
# / / +(
= #3
# $ 0 ) # # A 0
& - ) # 0 8) ! # . $ #
$ 0 ) # ) # 0
3 3 ;
7 *8
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Convert
/// </summary>
///
namespace John.AspNet.CS.Dll
{
public class Convert
{
public Convert()
{
//
// TODO: Add constructor logic here
//
}

4
& . .

public double FToC(double Fahrenheit)


{
return ((Fahrenheit - 32) * 5) / 9;
}

public double CToF(double Celsius)


{
return ((Celsius * 9) / 5) + 32;
}

}
}

) ) # 0 2 8 ) # $
) # 0
, ! " #
2 # # + # $ + 3 / $ A
0 $ A 0
# $ .# $ $ # $
A 0 # $ + 0 / $+
$+ $ # 0 # !# ) +
/
2 # $ A 0 6 8
/ .# . 9# 0 # / 9# $
0

( 8 # $ /
' - ( . 6 0 ( / 6 / )
: 5 $ / 0 + (. 0 /
# ( 6 0 ( /
#

&

(+ ( -6; $ (+ (
(; $ %
@ -6; ) @
(; #
+ -6;5 +

5
(; $ %
+ -6; 5 +
(; $ %

6 0 ( / 6 / ) 3 3 ;

6 0 ( / # ) 3 3 ;
7 # * -8
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >


<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong><span style="font-size: 14pt">Convert
Temperature<br />
</span></strong>
<br />
Temperature&nbsp;
<asp:TextBox ID="TempTextbox"
runat="server"></asp:TextBox>&nbsp;<asp:Button
ID="ConvertButton"
runat="server" OnClick="ConvertButton_Click"
Text="Convert" /><br />

+
& . .

<br />
Fahrenheit&nbsp; to&nbsp; Celsius: &nbsp;
<asp:Label ID="FToCLabel"
runat="server"></asp:Label><br />
<br />
Celsius&nbsp; to&nbsp; Fahrenheit: &nbsp;
<asp:Label ID="CToFLabel"
runat="server"></asp:Label>

</div>
</form>
</body>
</html>

6 9
& * 6 0 ( / 6 / ) . + # #3
@ # # #3 )
6 0 (# 0
0 /# #3 )
6 0 (# 0 3 3 ;
7 # * -* 8
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void ConvertButton_Click(object sender,
EventArgs e)
{
John.AspNet.CS.Dll.Convert
c = new John.AspNet.CS.Dll.Convert();
double t =
System.Convert.ToDouble(TempTextbox.Text);
FToCLabel.Text = c.FToC(t).ToString("0.0");
CToFLabel.Text = c.CToF(t).ToString("0.0");
}

+
, .
& 1 / # #36 0 ( ( #
@
* 6 0 ( / + . $
$+ (+ ( # #3 ) +

* # $ * + / 6
(# + # 0 * + - .
# $ / # $ $#

!
* # $ A 0 # * + /
9# $ / # $ 2 $ # $ # $
$+ # #3 / 0 $
+ . 8 ( ($ . /
# $ ## # 5 $ 3
& ) # 0 00 0
0 /# $$ 0 $ $$ $ )3
# $ # #;
csc /t:library /out:John.AspNet.CS.Dll.dll /r:System.dll
*.cs

## # $ # #0 $ # $$
* ) $ G) + 0 # $ $
+
& . .

# 5 $ 3 -0
# (# # $ # $$ .
5 $ 3 G ) + +0 /
# $$ 5 $ 3
/ 9# #3H $ . # . # #3 ) #
+. # #3 ) $ + + - $
+ . + 9# #3 G) + - +
) ( + (. $# J
% 0 ( /
) ( + (. 0
5 $ 3 5 $ 3 /
* #
<H # 0 <5 $ 3<) $+ #3?7 #
# /+ (

:
- ($ 0 / # $ #0 ;
& M ;+ 0 / % # $ #
$ #9 3 + 6 % (# + 0 P %
M ) $ 0 6 0 + #
+ # $
' M0 0 # % $ #0 $+
+ 3 $+ 2 # $
$ 0 + 3 $ $ 0 . 0
$ # $$ $#
0 /# 0# $ / ) #
0 6 0 0
# $ - # $$ # $ $+
$

+
; 9
# $ $ $ 3 # $ 6 0 %
## + / * +
& - ( / # #3 * + #
5 . # @ 5 # @ 0
0 * +
6 0 * + B@ 0
' 6 ) # 0 0 $ A 0 -0
8 ) # 0 ) # (
# . # ) # 0 #
6 0 # $+/ 0 #
/ ) # / # /
# $

++
& . .

, . .
2 8 * + / # $ / . $
# $ 6 0 @ 0 0 * +

& 1 / # #36 0 ( ( #
@
* 6 0 ( / + . $
$+ (+ ( # #3 ) +

# # &>

+/

You might also like