【发布时间】:2013-05-21 17:52:44
【问题描述】:
我需要使用 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 中。任何帮助将不胜感激。
【问题讨论】:
-
HTML 有必要吗?你不能只做一个 Http Post 吗?如果是这样,请查看this
-
我想提一下 iframe 的目标,如何在 http post 中做到这一点?
-
我不确定你的意思。你能澄清一下吗?
-
您只是想将来自外部页面的内容包含到您现有的页面 re: iFrame 中,还是希望有一个辅助页面/表单可用于在您的主页中进行交互/发布?
-
@Pheonixblade9 我的意思是说我在 http 帖子中如果我想提及我在这里提到的目标 action="localhost:2180/PrepDoc.aspx" method="post" target="my_frame"