人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

ASP.NET相關問題14問

ASP.NET相關問題14問

更新時間:2022-07-07 文章作者:未知 信息來源:網絡 閱讀次數:

1、ASP.NET能在那些系統中運行?

目前,ASP.NET還只能奔跑在微軟的Windows 2000、Windows XP和Windows 2003的系統中,并且需要微軟Internet Information Server(IIS)的支持,微軟原計劃要讓Windows NT4.0也支持ASP.NET,但可能微軟是有些技術問題或市場考慮,還沒有實現NT下的ASP.NET的支持。

2、在一個ASPX文件中是否可以使用一種以上的語言?

答案讓你有點失望,雖然微軟的提供了公共語言運行環境(CLR,Common Laguage Runtime),實現了多種編程語言間的緊密集成,可以允許你從一個VB對象中導出C#所需的對象來,但一個ASPX文件中只能用一種語言,正如你不能在VB.NET中使用C#的語法一樣。

3、ASPX文件的服務器端腳本支持那些語言?

目前,ASPX文件只支持C#、Visual Basic.NET、Jscript.NET和J#,但是你使用code—behind(代碼分離)的方法創建一個獨立代碼文件,你就可以使用任何.NET編譯器支持的語言來實現功能了。

4、在Global.asax文件中能使用code—behind(代碼分離)技術嗎?

當然可以了,例如:
Global.asax:
<script language=VB" runat="server">
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
</script>
和使用code—behind(代碼分離)技術
Global.asax:
<%@ Application Inherits="MyApp" %>
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文件中包含<%@ Page Debug="true" %>命令或Web.config中聲明了<compilation debug="true">時,你就可以在系統目錄下的Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files中找到ASPX文件在ASP.NET下生成的文件。

6、在ASPX文件中如何注釋呢?

同ASP文件中的方法一樣。
<%--
response.write "測試!"
--%>

7、ASPX文件中是否可以存在一個以上服務器端 Form 標記?

不可以

8、我可以在Web窗體中使用自定義數據類型嗎

可以,你可以把包含自定義數據類型的DLL文件放在程序根目錄下的BIN目錄中,ASP.NET會在數據類型引用時,裝載DLL文件的。

9、我能在Global.asax文件中觸發那些事件?
Application對象創建和結束時所觸發的事件有
&#61548; Application_Start
&#61548; Application_End
Session對象創建和結束時所觸發的事件有
&#8226; Session_Start
&#8226; Session_End
對程序有請求發生時觸發的事件有 (按發生順序排列)
&#8226; Application_BeginRequest
&#8226; Application_AuthenticateRequest
&#8226; Application_AuthorizeRequest
&#8226; Application_ResolveRequestCache
&#8226; Application_AcquireRequestState
&#8226; Application_PreRequestHandlerExecute
&#8226; Application_PostRequestHandlerExecute
&#8226; Application_ReleaseRequestState
&#8226; Application_UpdateRequestCache
&#8226; Application_EndRequest
當有程序有錯誤發生時觸發的事件有
&#8226; Application_Error
&#8226; 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默認導入的名稱空間可以直接引用了,使用其它的名稱空間就的自行導入了。

默認名稱空間
&#61548; System
&#61548; System.Collections
&#61548; System.Collections.Specialized
&#61548; System.Configuration
&#61548; System.Text
&#61548; System.Text.RegularExpressions
&#61548; System.Web
&#61548; System.Web.Caching
&#61548; System.Web.Security
&#61548; System.Web.SessionState
&#61548; System.Web.UI
&#61548; System.Web.UI.HtmlControls
&#61548; 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"
message.To = "web3@163.com"
message.Subject = "測試"
message.Body = "內容"
Mail.SmtpMail.SmtpServer = "localhost"
Mail.SmtpMail.Send(message)

14、我將如何通過ADO.NET讀取數據庫中的圖片并顯示它呢?

下面舉一個從Microsoft SQL Server的PUB數據庫讀取圖片并顯示它的例子:
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_load(Sender as Object, E as EventArgs)
dim stream as new MemoryStream
dim connection as SqlConnection
connection=new SqlConnection("server=localhost;database=pubs;uid=sa;pwd=")
try
connection.Open()
dim command as SqlCommand
command = new SqlCommand ("select logo from pub_info where pub_id='0736'", connection)
dim image as byte()
image = command.ExecuteScalar ()
stream.Write (image, 0, image.Length)
dim imgbitmap as bitmap
imgbitmap = new Bitmap (stream)
Response.ContentType = "image/gif"
imgbitmap.Save (Response.OutputStream, ImageFormat.Gif)
Finally
connection.Close()
stream.Close()
End Try
End Sub
</script>

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 威海市| 中牟县| 日照市| 原阳县| 达州市| 安庆市| 澄迈县| 修文县| 孟津县| 吴桥县| 镇雄县| 察隅县| 阜新| 广东省| 广灵县| 西昌市| 永康市| 乃东县| 济阳县| 收藏| 金溪县| 新龙县| 泽库县| 耿马| 黄骅市| 清新县| 保山市| 鄂尔多斯市| 林甸县| 鄯善县| 昭苏县| 天气| 达尔| 贵定县| 楚雄市| 将乐县| 泰来县| 阜阳市| 杭锦后旗| 贵州省| 绥化市|