2007-10-17

ASP.NET热点问题解答14个

来源: 本站收集整理 作者: 评论 0 条
 

当有程序有错误发生时触发的事件有

• 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"
共3页: 上一页 [1] 2 [3] 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:ASP向ASP.AET 环境迁移需要考虑的问题  
下一篇:MySQL与ASP.NET配合
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号