当有程序有错误发生时触发的事件有
• Application_Error
• Application_Disposed
10、Web控件是否支持样式表(CSS)呢?
Yes. All Web controls inherit a property named CssClass from the base class System.Web.UI.WebControls.WebControl. The following example defines a CSS class named Input and uses it to modify a TextBox control to display text in red 10-point Verdana type:
支持,所有的Web控件都从基类System.Web.UI.WebControls.WebControl中继续了一个叫做CssClass的属性。
例如:
<html>
<head>
<style>
.Input { font: 10pt verdana; color: red; }
</style>
</head>
<body>
<form runat="server">
<asp:TextBox CssClass="Input" RunAt="server" />
</form>
</body>
</html>
11、在ASPX文件中默认导入那些名称空间?
ASPX默认导入的名称空间可以直接引用了,使用其它的名称空间就的自行导入了。
默认名称空间
System
System.Collections
System.Collections.Specialized
System.Configuration
System.Text
System.Text.RegularExpressions
System.Web
System.Web.Caching
System.Web.Security
System.Web.SessionState
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls
12、我是否可以自己创建服务器控件呢?
可以,创作您自己的 ASP.NET 服务器控件很轻易。创建简单的自定义控件时,您所要做的只是定义从 System.Web.UI.Control 派生的类并重写它的 Render 方法。Render 方法采用 System.Web.UI.HtmlTextWriter 类型的参数。控件要发送到客户端的 HTML 作为字符串参数传递到 HtmlTextWriter 的 Write 方法。
例如:
服务器控件代码(简单显示字符串):Simple.vb:
Imports System
Imports System.Web
Imports System.Web.UI
Namespace SimpleControlSamples
Public Class SimpleVB : Inherits Control
Protected Overrides Sub Render(Output As HtmlTextWriter)
Output.Write("<H2>欢迎使用控件开发!</H2>")
End Sub
End Class
End Namespace
引用文件Simple.aspx:
<%@ Register TagPrefix="SimpleControlSamples" Namespace="SimpleControlSamples" Assembly="SimpleControlSamplesVB" %>
<html>
<body>
<form method="POST" action="Simple.aspx" runat=server>
<SimpleControlSamples:SimpleVB id="MyControl" runat=server/>
</form>
</body>
</html>
13、如何在ASP.NET程序中发送邮件呢?
在ASP.NET程序中发送邮件不再象ASP中那样需要组件的支持了,在.NET的框架基类的System.Web.Mail名称空间内包含的MailMessage和SmtpMail类可以实现这个功能。
例如:
Dim message As new Mail.MailMessage
message.From = "web3@163.com"
评论加载中…
![]() |