SoFunction
Updated on 2025-04-08

14 hot questions answered

 
1. Which systems can it run in?

At present, it can only run in Microsoft's Windows 2000, Windows XP and Windows 2003 systems, and requires the support of Microsoft Internet Information Server (IIS). Microsoft originally planned to support Windows NT4.0, but Microsoft may have some technical issues or market considerations, and has not yet implemented support under NT.

2. Can more than one language be used in an ASPX file?

The answer is a bit disappointing. Although Microsoft provides a common language running environment (CLR, Common Laguage Runtime), implementing tight integration between multiple programming languages, allowing you to export the objects required by C# from a VB object, only one language can be used in an ASPX file, just as you cannot use the C# syntax in it.

3. Which languages ​​does the server-side script of ASPX files support?

Currently, ASPX files only support C#, Visual, and J#, but if you use the code-behind (code separation) method to create a separate code file, you can use any language supported by the .NET compiler to implement the functionality.

4. Can code-behind (code separation) technology be used in files?

Of course, for example:
: 
 
and use code-behind (code separation) technology
: 
 

Imports  
Imports  
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("online_session") = CInt(Application("online_session")) + 1 
() 
End Sub 
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) 
() 
Application("online_session") = CInt(Application("online_session")) - 1 
() 
End Sub 
End Class 
5. Can I see the code generated in the ASPX file?

As you can see, when your ASPX file contains commands or declares it, you can find the files generated by the ASPX file in the \Framework\v1.\Temporary  Files in the system directory.

6. How to comment in ASPX files?

The same method as in ASP files.
 

7. Can more than one server-side Form tag exist in the ASPX file?

Can't

8. Can I use custom data types in web forms?

Yes, you can place the DLL file containing the custom data type in the BIN directory at the root of the program, and will load the DLL file when the data type is referenced.

9. What events can I trigger in the 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 a request for the program occurs (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 an error occurs in a program.
• Application_Error 
• Application_Disposed 
10. Do web controls support stylesheets (CSS)?

Yes. All Web controls inherit a property named CssClass from the base class . 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: 

Supported, all web controls inherit a property called CssClass from the base class.
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. What namespaces are imported by default in ASPX files?

The namespace imported by ASPX can be directly referenced, and you can import it yourself using other namespaces.

Default namespace
 System 
  
  
  
  
  
  
  
  
  
  
  
  
12. Can I create server controls by myself?

Yes, it's easy to create your own server controls. When creating a simple custom control, all you have to do is define the class derived from and override it's Render method. The Render method takes parameters of type. The HTML that the control is to be sent to the client is passed as a string parameter to the Write method of the HtmlTextWriter.
For example:
Server control code (simple display of string)::
    Imports System 
    Imports  
    Imports  

    Namespace SimpleControlSamples 

    Public Class SimpleVB : Inherits Control 

    Protected Overrides Sub Render(Output As HtmlTextWriter) 
("<H2>Welcome to use control development!</H2>")
    End Sub 
    End Class 
    End Namespace 
Quote file:
    <%@ Register TagPrefix="SimpleControlSamples" Namespace="SimpleControlSamples" Assembly="SimpleControlSamplesVB" %> 

    <html> 
    <body> 
    <form method="POST" action="" runat=server> 
    <SimpleControlSamples:SimpleVB  runat=server/> 
    </form> 
    </body> 
    </html> 

13. How to send emails in the program?

Sending mail in a program no longer requires component support like in ASP. This function can be achieved by MailMessage and SmtpMail classes contained in the namespace of the .NET framework base class.
For example:
Dim message As new  
 = "web3@" 
 = "web3@" 
= "Test"
= "Content"
 = "localhost" 
(message) 

14. How will I read the image in the database and display it?

Here is an example of reading a picture from the PUB database of Microsoft SQL Server and displaying it:
Here is an example of reading a picture from the PUB database of Microsoft SQL Server and displaying it:
    <%@ Import Namespace="" %> 
    <%@ Import Namespace="" %> 
    <%@ Import Namespace="" %> 
    <%@ Import Namespace="" %> 
    <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 
    () 
    dim command as SqlCommand 
    command = new SqlCommand ("select logo from pub_info where pub_id='0736'", connection) 
    dim image as byte() 
    image =  () 
     (image, 0, ) 
    dim imgbitmap as bitmap 
    imgbitmap = new Bitmap (stream) 
     = "image/gif" 
     (, ) 
    Finally 
    () 
    () 
    End Try 
    End Sub 
    </script>