MyApp.vb: imports System.Web imports System.Web.SessionState Public Class MyApp Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) Application("online_session") = 0 End Sub Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Application.Lock() Application("online_session") = CInt(Application("online_session")) + 1 Application.UnLock() End Sub Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) Application.Lock() Application("online_session") = CInt(Application("online_session")) - 1 Application.UnLock() End Sub End Class 5、我能否看到ASPX文件在ASP.NET中生成的代码吗?
可以看到的,当你的ASPX文件中包含命令或Web.config中声明了时,你就可以在系统目录下的Microsoft.NETframeworkv1.0.nnnnTemporary ASP.NET Files中找到ASPX文件在ASP.NET下生成的文件。
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:
可以,创作您自己的 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("欢迎使用控件开发!") End Sub End Class End Namespace 引用文件Simple.aspx: <%@ Register TagPrefix="SimpleControlSamples" Namespace="SimpleControlSamples" Assembly="SimpleControlSamplesVB" %>
13、如何在ASP.NET程序中发送邮件呢?
在ASP.NET程序中发送邮件不再象ASP中那样需要组件的支持了,在.NET的框架基类的System.Web.Mail名称空间内包含的MailMessage和SmtpMail类可以实现这个功能。 例如: Dim message As new Mail.MailMessage message.From = "web3@163.com" message.To = "web3@163.com" message.Subject = "测试" message.Body = "内容" Mail.SmtpMail.SmtpServer = "localhost" Mail.SmtpMail.Send(message)