2013-05-21 41 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「);」 –