[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Posting Data

Posted on 2011-05-03
7
Medium Priority
?
459 Views
Last Modified: 2013-11-07
Hello Partners,

Could anyone please give me a small example of how to send information to another page/application using "POST". Something like that: One page that sends the content of two asp.net text boxes to another page, and how the second page receives it.

Important things: I'm not talking about Session, QueryString, ViewState, ..... It's about WebRequest i guess...

Thank you
0
Comment
Question by:tbsolutions
  • 4
  • 2
7 Comments
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 35516103
use Postbackurl property of the button and give the name of the page where do u want to post the data.Get the control's value on second page by using
Previouspage.Findcontrol("ID")

OR

Try "System.Collections.Specialized.NameValueCollection"
How it ll work?
 just use server.transfer
 now if u want 2 send "textbox1.text's text" which is on your first page.
 add this code to your second page-

System.Collections.Specialized.NameValueCollection tmpform = default(System.Collections.Specialized.NameValueCollection);
tmpform = Request.Form;
textbox2.Text = tmpform.Item("textbox1");

 Textbox2 is a textbox located on ur second page in which u want the value.
 Ur done but use of frames is not recommended although it will work
Hope thats the answer.
0
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 35516798
Hi, also you can make use of Previouspage in a strong type way, by using an interface that exposes your source page members that you want to access from the other page, see the attached example:
PreviousPageExample.zip
0
 
LVL 3

Author Comment

by:tbsolutions
ID: 35689511
techChallenger1 & yv989c, thanks for the responses!

Your suggestions worked when i had two pages inside the same application, but when i tried a cross-application situation, it didn't work.
Take a look on the image i attached, any suggestion is welcome.

Thank you!! Scenario
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 35690270
Yes, it can be done, can you open this example that I made for you?
PostExample.zip

Default page on PostExampleA:
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            <br />
            <asp:Button ID="Button1" runat="server" Text="Save Text Values" />
        </div>
        </form>
        <form action="http://localhost:40001/PostExampleB/Default.aspx" method="post">
        <input type="hidden" name="text1" value="<%= TextBox1.Text %>" />
        <input type="hidden" name="text2" value="<%= TextBox2.Text %>" />
        <input type="submit" name="Submit" value="Call the Other Page" />
    </div>
    </form>
</body>
</html>

Open in new window



Default page on PostExampleB:
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = Request.Form["text1"];
        Label2.Text = Request.Form["text2"];
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server"></asp:Label>
        <br />
        <asp:Label ID="Label2" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

Open in new window


On PostExampleA, first click the button "Save Text Values", then click "Call the Other Page".

If you are using the ASPNET Development Server it is important that you fix the port number of PostExampleB web site to 40001.

I dont know what VS version you have, so the solution file attached may dont work for you (I have VS2010).
0
 
LVL 17

Accepted Solution

by:
Carlos Villegas earned 1500 total points
ID: 35690391
Oh sorry, while Im cleaning up my code I messed it..., please replace the code on the Default.aspx page in PostExampleA with this:
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Save Text Values" />
    </div>
    </form>
    <form action="http://localhost:40001/PostExampleB/Default.aspx" method="post">
    <input type="hidden" name="text1" value="<%= TextBox1.Text %>" />
    <input type="hidden" name="text2" value="<%= TextBox2.Text %>" />
    <input type="submit" name="Submit" value="Call the Other Page" />
    </form>
</body>
</html>

Open in new window

0
 
LVL 3

Author Closing Comment

by:tbsolutions
ID: 35698058
It worked partially.. Thanks!
0
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 35698113
Hi, thank you.

Yes, it is not perfect, in fact you can do a post directly to your other application and make it works, but it need special configuration in both application to match the same encryption key, without that the viewstate mac validation will fail, so I did prefer to post this simple solution for you.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question