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 ),Programming LanguageClose integration between objects allows you to export the objects required by C # From a VB object, but An ASPX file can only use one language, just as you cannot export files in VB. net uses the same C # syntax.
3. Which languages does aspx file server scripts support?
Currently, the aspx file only supports C #, Visual Basic. net, JScript. net, and J #, but you use code-behind (CodeTo create an independent code file, you can use any language supported by the. NET compiler to implement the function.
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 place the DLL files that contain Custom Data Types inProgramIn the bin directory under the root directory, ASP. NET loads 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
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. 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>