使用C#发布表单

时间:2013-05-21 17:52:44

标签: c# forms post

我需要使用C#将数据发布到其他网站。

<form action="http://localhost:2180/PrepDoc.aspx" method="post" target="my_frame" >
    <input type="text" name="someText" value="Some Text" />
    <input type="submit" runat="server" />
</form>
<iframe id="myIframe" name="my_frame" runat="server" >

这工作正常,但我需要使用c#来做到这一点。

在我尝试使用onclick按钮代码发布数据之前,有人可以指导我,但它需要我不想要的prepdoc页面。

HttpResponse httpResponse = HttpContext.Current.Response;
httpResponse.Clear();

httpResponse.Write("<html><head></head>");
httpResponse.Write(string.Format(
    "<body onload=\"document.{0}.submit()\">",
    "frmCart"));
httpResponse.Write(string.Format(
    "<form name=\"{0}\" method=\"{1}\" action=\"{2}\" target=\"my_frame\">", 
    "frmCart",
    "Post",
    "http://localhost:2180/PrepDoc.aspx"));
httpResponse.Write("</form>");
httpResponse.Write("</body></html>");

httpResponse.End();

我想将它放在默认页面(来电者页面)和iFrame中。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

这个页面是一个很好的资源:

http://msdn.microsoft.com/en-us/library/6c3yckfw(v=vs.100).aspx

在那里你也可以找到一些代码片段。 请享用。

问候 约翰尼

答案 1 :(得分:0)

Source page : Session("value") = value;
Destination page : value = Session("Value");