Asp. NET Hot Issues Answer 14

Source: Internet
Author: User
Tags mail microsoft sql server requires mailmessage root directory| Solutions | questions 1, ASP. NET can run in those systems

Currently, ASP. NET can only run on Microsoft Windows 2000, Windows XP and Windows 2003 systems, and requires Microsoft Internet Information Server (IIS) support, Microsoft is scheduled to let Windows NT4.0 also supports, but it is possible that Microsoft has some technical issues or market considerations and has not yet implemented NT's support.

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

The answer is a bit disappointing, although Microsoft offers a common language runtime (Clr,common laguage Runtime) that enables tight integration between multiple programming languages, allowing you to export the objects needed for C # from a VB object, but only one language in an ASPX file Just as you can't use C # 's syntax in

   3. The server-side script for ASPX files support those languages?

Currently, ASPX files only support C #, Visual Basic.NET, JScript.NET, and J #, but you use Code-behind (code-separated) method to create a stand-alone code file, you can use any. NET compiler to enable the functionality of the language.

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

Of course you can, for example:

and using Code-behind (code separation) technology

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

As you can see, when your ASPX file contains commands or web.config in the declaration, you can\framework\v1.0.nnnn\temporary in the system directory Files that are generated by the aspx file in

   6, in the ASPX file how to annotate it?

Same as the methods in ASP files.

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


   8. Can I use a custom data type in a Web form?

OK, you can put the DLL file containing the custom data type in the Bin directory under the program root directory, 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 terminated are
The events that are triggered when the session object is created and ended are
Events that are triggered when a request for a program occurs (in order of occurrence)
An event that is 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:

. Input {font:10pt verdana; color:red;}
<form runat= "Server" >
<asp:textbox cssclass= "Input" runat= "Server"/>

   11. Which namespaces are imported by default in ASPX files?

The ASPX default import namespace can be referenced directly and imported using other namespaces.

Default namespace

12. Can I create my own server control?

You can, authoring your own server control is easy. When you create a simple custom control, all you have to do is define a class derived from System.Web.UI.Control and override its Render method. The Render method takes parameters of the System.Web.UI.HtmlTextWriter type. The HTML that the control sends to the client is passed to the HtmlTextWriter Write method as a string parameter.
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 use control development!") </H2> ")
End Sub
End Class
End Namespace
Referencing file simple.aspx:
<%@ Register tagprefix= "simplecontrolsamples" namespace= "Simplecontrolsamples" assembly= "%>

<form method= "POST" action= "simple.aspx" runat=server>
<simplecontrolsamples:simplevb id= "MyControl" runat=server/>

   13, how to send the mail in the program?

Sending mail in a program no longer requires component support in the same way as an 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 picture in the database through and show it?

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"%>
<%@ 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=")
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)
Connection. Close ()
Stream. Clse ()
End Try
End Sub

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.