• λ我爱Aspx >> Asp.Net >> 在ASP.NET中实现POST发送数据
  • 在ASP.NET中实现POST发送数据

  • :aspxer  Դ:网络  :2007-4-25 21:17:33  ؼ:.net,asp.net,asp,数据
  • 在ASP.NET中实现POST发送数据 作者:孟宪会 出自:【孟宪会之精彩世界】 发布日期:2003年6月27日 8点13分41秒


    下面的代码实现了与以前XMLHTTP类似的功能。代码如下:

    HttpSendData.aspx

    <%@ page language="c#"%> <%@ import namespace = "system"%> <%@ import namespace = "system.collections"%> <%@ import namespace = "system.web"%> <%@ import namespace = "system.web.ui"%> <%@ import namespace = "system.web.ui.webcontrols"%> <%@ import namespace = "system.net"%> <%@ import namespace = "system.io"%> <%@ import namespace = "system.text"%> <!doctype html public "-//w3c//dtd html 4.0 transitional//en" > <html> <head> void Button1_Click(object sender, System.EventArgs e) &#123; string strTitle = TextBox1.Text; string strDesc = TextBox2.Text; Encoding encoding = Encoding.GetEncoding("GB2312"); string postData = "Title=" + strTitle; string strUrl = "http://xml.sz.luohuedu.net/HttpReceiveData.aspx"; postData += ("&Desc=" + strDesc); byte[] data = encoding.GetBytes(postData); // 准备请求... HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrl); myRequest.Method = "POST"; myRequest.ContentType="application/x-www-form-urlencoded"; myRequest.ContentLength = data.Length; Stream newStream=myRequest.GetRequestStream(); // 发送数据 newStream.Write(data,0,data.Length); newStream.Close(); Response.Redirect("HttpSendData.aspx"); &#125; </head> <body> <form id="httppost" method="post" runat="server"> 标题:</asp:textbox> </p> <p> 内容: </p> <p> </asp:textbox> </p> <p> </asp:button> </form> </body> </html>

    Ҷƪл˵?
  • һƪ从SQL Server数据库提取图片并显示在DataGrid
    һƪ利用OleDb的GetOLEDBSchemaTable方法得到数据库架构信息