0

I need to post data to other website using 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" >

this is working fine but i need to do this using c#.

can some one guide me before i was trying to post data using onclick button code but it takes to the prepdoc page that i dont want .

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();

I want this to be on Default page (caller page) and in iFrame. Any help will be appreciated.

Gustavo Mori
  • 8,319
  • 3
  • 38
  • 52
Salman
  • 1,266
  • 5
  • 21
  • 41
  • Is the HTML necessary? Can't you just do an Http Post? If so, take a look at [this](http://stackoverflow.com/questions/4015324/http-request-with-post) – Codeman May 21 '13 at 17:59
  • i want to mention target for iframe how can i do that in http post ? – Salman May 21 '13 at 18:04
  • I'm not sure what you mean. Could you please clarify? – Codeman May 21 '13 at 18:05
  • Are you just looking to include content from an external page into your existing page re: the iFrame or are you wanting to have a secondary page/form be available for interaction/posting within your main page? – Dave May 21 '13 at 18:05
  • @Pheonixblade9 i meant to say that i in http post if i want to mention target that i mentioned here action="http://localhost:2180/PrepDoc.aspx" method="post" target="my_frame" – Salman May 21 '13 at 18:08
  • From your comment above (just got), you want to dynamically change the iframe target on post (i.e. user selects options and then posts and then loads your iframe with the desired selection)? – Dave May 21 '13 at 18:08
  • @Dave yes i wanted it to be in iframe . i want to post data to external page but let it be iframe i dont want to move to the external page. – Salman May 21 '13 at 18:09
  • Check out article... http://stackoverflow.com/questions/9787250/iframe-with-dynamically-set-source HTH Dave – Dave May 21 '13 at 18:17

2 Answers2

0

a good resource is this page:

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

There you can find some code snippets, too. Enjoy.

Greetings Johnny

Johnny
  • 1
0
Source page : Session("value") = value;
Destination page : value = Session("Value");
Ehsan Keramat
  • 164
  • 2
  • 6
  • Please add some context to explain this answer. – Gordon Seidoh Worley May 25 '13 at 00:35
  • whatever you want send to the other page you can use that code, for example you wanna send result of the query or a integer or string, you can send it to the "session("Value")= value; " then in the Destination page receive it "value = Session("Value");" – Ehsan Keramat May 25 '13 at 00:40