2013-05-21 43 views
0

我需要使用C#将数据发布到其他网站。使用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。任何帮助将不胜感激。

+0

是HTML有必要吗?你不能只是做一个Http Post?如果是这样,看看[这](http://stackoverflow.com/questions/4015324/http-request-with-post) – Codeman

+0

我想提iframe的目标我怎么能在http post? – Salman

+0

我不确定你的意思。你能澄清一下吗? – Codeman

回答

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

请添加一些背景来解释这个答案。 –

+0

无论你想发送到其他页面你可以使用该代码,例如你想发送查询结果或一个整数或字符串,你可以发送到“session(”Value“)= value;”然后在目标页面接收它“value = Session(”Value“);” –