Asp. NET some of the classic questions

Source: Internet
Author: User
Tags how to send mail mailmessage
1, ASP. NET can run on those systems?

Currently, ASP. NET can only run in Microsoft Windows 2000, Windows XP and Windows 2003 systems, and requires Microsoft Internet Information Server (IIS) support, Microsoft has planned to let Windows NT4.0 also supports ASP. NET, but maybe Microsoft has some technical problems or market considerations, and has not implemented the support of the NT ASP.

2. Is it possible to use more than one language in an ASPX file?

The answer is a bit disappointing, though Microsoft's offer of a common language runtime (Clr,common laguage runtime) enables tight integration between a variety of programming languages, allowing you to export the objects required by C # from a VB object, but only one language in an ASPX file, Just as you can't use C # syntax in

3. What languages does the server-side script for ASPX files support?

Currently, ASPX files only support C #, Visual Basic.NET, JScript.NET, and J #, but you can use any if you create a standalone code file using the Code-behind (Code separation) method. NET compiler supports the functionality of the language.

4. Can I use Code-behind (code separation) technology in the Global.asax file?

Of course you can, for example:
and using Code-behind (code separation) technology

Global.asax:  Myapp.vb:  Imports system.web  imports System.Web.SessionState public  Class myapp< c5/> Sub Application_Start (ByVal sender as Object, ByVal e as EventArgs)  application ("online_session") = 0  En D Sub  Sub Session_Start (ByVal sender as Object, ByVal e as EventArgs)  Application.Lock ()  application ("O Nline_session ") = CInt (Application (" Online_session ")) + 1  application.unlock ()  End Sub  Sub Session_en D (ByVal sender as Object, ByVal e as EventArgs)  Application.Lock ()  application ("online_session") = CInt (Appl Ication ("Online_session"))-1  application.unlock ()  end Sub  End Class  

5. Can I see the code generated by the ASPX file in ASP.

As you can see, when your ASPX file contains commands or is declared in Web. config, you can\framework\v1.0.nnnn\temporary ASP. NET in the system directory Files, locate the file that is generated by the ASPX file under ASP.

6. How do I annotate in an aspx file?

The same way as in ASP files.

7. Can there be more than one server-side Form tag in an aspx file?


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, ASP. NET loads the DLL file when the data type is referenced.

9. Can I trigger those events in the Global.asax file?
The events that are triggered when the Application object is created and ended are
Events that are triggered when the session object is created and ended
Events that are triggered when a request for a program occurs (in order of occurrence)
Events that are triggered when a program has an error occurs
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-po int Verdana Type:

Support, all Web controls inherit a property called CssClass from the base class System.Web.UI.WebControls.WebControl.
For example:

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 the use of control development! </H2> ")      end Sub      end Class      End Namespace

Reference file Simple.aspx:

<%@ Register tagprefix= "simplecontrolsamples" namespace= "Simplecontrolsamples" assembly= "SimpleControlSamplesVB "%>      

13. How to send mail in ASP.

Sending mail in an ASP is no longer required by the component in ASP, and the MailMessage and SmtpMail classes contained within the System.Web.Mail namespace of the. NET Framework base class can implement this functionality.
For example:

Dim message as new mail.mailmessage  message. from = ""  message. to = ""  message. Subject = "Test"  message. Body = "Content"  Mail.SmtpMail.SmtpServer = "localhost"  Mail.SmtpMail.Send (Message)

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

Here's an example of reading a picture from a pub database in Microsoft SQL Server and displaying it:
Here's an example of reading a picture from a pub database in Microsoft SQL Server and displaying it:

  <%@ import namespace= "System.Data.SqlClient"%> <%@ Import namespace= "System.Drawing"%> <%@ Im  Port 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 conn Ection as SqlConnection connection=new SqlConnection ("server=localhost;database=pubs;uid=sa;pwd=") Try Conn Ection. Open () Dim command As SqlCommand command = new SqlCommand ("Select logo from pub_info where pub_id= ' 0736 '", Conn ection) 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" img Bitmap. Save (Response.outputstream, imageformat.gif) Finally connection. Close () stream. Clse () End Try End Sub </script> 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.