asp.net|数据下面的代码实现了与以前XMLHTTP类似的功能。代码如下:
HttpSendData.ASPx
<% Page language="<a runat="server">
void Button1_Click(object sender, System.EventArgs e)
{
string strTitle = TextBox1.Text;
string strDesc = TextBox2.Text;
Encoding encoding = Encoding.GetEncoding("GB2312");
string postData = "Title=" + strTitle;
string strUrl = "http://<a
</HEAD>
<body>
<form id="HTTPPost" method="post" runat="server">
标题:<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
内容:
<asp:TextBox id="TextBox2" runat="server" TextMode="MultiLine" Rows="10" Columns="100"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text=" 发 送 " ></asp:Button>
</form>
</body>
</HTML>
HttpReceiveData.aspx
<% Page Language="vb"%>
<% import Namespace = "System" %>
<% import Namespace = "System.Web.UI" %>
<% import Namespace = "System.Web" %>
<script runat="server">
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Request.ServerVariables("REQUEST_METHOD").ToString() = "POST" Then
Dim connstr As String
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Test.mdb")
Dim cn As New System.Data.OleDb.OleDbConnection(connstr)
Dim strSQL As String = "INSERT INTO TestTable (Title,Description) VALUES('" _
+ Request.Form("Title").ToString() + "','" + Request.Form("Desc").ToString() + "')"
cn.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand(strSQL, cn)
cmd.ExecuteNonQuery()
cn.Close()
cn.Dispose()
cmd.Dispose()
End If
End Sub
</script>
在ASP.NET中实现POST发送数据
80酷酷网 80kuku.com