手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Asp.Net编程>列表

ASP.NET热点问题解答14个

来源:互联网 作者:west263.com 时间:2008-02-22
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

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>欢迎使用控件开发!</H2>")
End Sub
End Class
End Namespace
引用文件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、如何在ASP.NET程序中发送邮件呢?

  在ASP.NET程序中发送邮件不再象ASP中那样需要组件的支持了,在.NET的框架基类的System.Web.Mail名称空间内包含的MailMessage和SmtpMail类可以实现这个功能。
  例如:
  Dim message As new Mail.MailMessage
  message.From = "web3@163.com"
  message.To = "web3@163.com"
  message.Subject = "测试"
  message.Body = "内容"
  Mail.SmtpMail.SmtpServer = "localhost"
  Mail.SmtpMail.Send(message)

  14、我将如何通过ADO.NET读取数据库中的图片并显示它呢?

  下面举一个从Microsoft SQL Server的PUB数据库读取图片并显示它的例子:
  下面举一个从Microsoft SQL Server的PUB数据库读取图片并显示它的例子:
<%@ 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='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)
Finally
connection.Close()
stream.Clse()
End Try
End Sub
</script>

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!