1. Which systems can ASP. NET run?
Currently, ASP. NET can only run on Microsoft Windows 2000, Windows XP, and Windows 2003 systems, and requires support from Microsoft Internet Information Server (IIS, microsoft originally planned to allow Windows NT4.0 to support ASP. however, Microsoft may have some technical issues or market considerations and has not implemented ASP.. NET.
2. Can I use more than one language in An ASPX file?
The answer is a bit disappointing. Although Microsoft provides a Common Language Runtime (CLR), it implements close integration between multiple programming languages, you can export the required objects of C # From a VB object, but only one language can be used in An ASPX file, just as you cannot export them in VB. NET uses the same C # syntax.
3. Which languages does ASPX file server scripts support?
Currently, ASPX files only support C # and Visual Basic. NET, Jscript. NET and J #, but you can use the code-behind (code separation) method to create an independent code file, you can use any.. NET compiler supports the language.
4. Can code-behind (code separation) Be used in the Global. asax file?
Of course. For example:
Global. asax:
And use code-behind (code separation) Technology
Global. asax:
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. Can I see the code generated by the ASPX file in ASP. NET?
As you can see, when your ASPX file contains commands or Web. when the config file is clear, you can go to the Microsoft. NET \ Framework \ v1.0.nnnn \ Temporary ASP. NET Files find the ASPX file in ASP.. NET.
6. How to comment in the ASPX file?
The method is the same as that in ASP files.
7. Can the ASPX file contain more than one Form tag on the server?
No
8. Can I use custom data types in Web forms?
Yes. You can put the DLL file containing the Custom Data Type in the BIN directory under the program root directory. ASP. NET will load the DLL file when the data type is referenced.
9. What events can I trigger in the Global. asax file?
The events triggered when the Application object is created and ended are:
Application_Start
Application_End
The events triggered when the Session object is created and ended are
• Session_Start
• Session_End
Events triggered when requests occur to programs (arranged in order of occurrence)
• Application_BeginRequest
• Application_AuthenticateRequest
• Application_AuthorizeRequest
• Application_ResolveRequestCache
• Application_AcquireRequestState
• Application_PreRequestHandlerExecute
• Application_PostRequestHandlerExecute
• Application_ReleaseRequestState
• Application_UpdateRequestCache
• Application_EndRequest
Events triggered when a program has an error
• Application_Error
• Application_Disposed
10. Does the Web Control Support Style Sheets (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:
Yes. All Web controls inherit a property called CssClass from the base class System. Web. UI. WebControls. WebControl.
For example:
<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. Which namespaces are imported by default in the ASPX file?
By default, the imported namespace of ASPX can be referenced directly, and Other Namespaces can be used for self-import.
Default namespace
Using System
Using System. Collections
Using System. Collections. Specialized
Using System. Configuration
Using System. Text
Using System. Text. RegularExpressions
Using System. Web
Using System. Web. Caching
Using System. Web. Security
Using System. Web. SessionState
Using System. Web. UI
Using System. Web. UI. HtmlControls
Using System. Web. UI. WebControls
12. Can I create my own server controls?
Yes. You can easily create your own ASP. NET Server controls. When creating a simple custom Control, all you have to do is define the class derived from System. Web. UI. Control and override its Render method. The Render method uses System. Web. UI. HtmlTextWriter parameters. The control sends the HTML to the client as a string parameter to the Write method of HtmlTextWriter.
For example:
Server Control Code (Simple display string): 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> welcome to control development! </H2> ")
End Sub
End Class
End Namespace
Reference file 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. How can I send emails in ASP. NET programs?
In ASP. in the. NET program, sending emails no longer requires the support of components as in ASP. NET Framework base class System. web. the MailMessage and SmtpMail classes in the Mail namespace can implement this function.
For example:
Dim message As new Mail. MailMessage
Message. From = "web3@163.com"
Message. To = "web3@163.com"
Message. Subject = "test"
Message. Body = "content"
Mail. SmtpMail. SmtpServer = "localhost"
Mail. SmtpMail. Send (message)
14. How can I read and display images in the database through ADO. NET?
The following is an example of reading an image from the PUB database of Microsoft SQL Server and displaying it:
The following is an example of reading an image from the PUB database of Microsoft SQL Server and displaying it:
<% @ 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 = '2013'", 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. Clse ()
End Try
End Sub
</Script>