Solved

Transfer Session Variables from Classic ASP to ASP.NET: Populate form

Posted on 2007-11-23
3
2,125 Views
Last Modified: 2008-02-13
I am using the article found here
http://www.eggheadcafe.com/articles/20021207.asp
(The downloaded code, shows how to go from aspx to asp)

I am sending form data from an aspx page to an asp page.
I want it to populate a form on an asp page.  
I can send the session data ok.
But how can I get it to populate existing form fields instead of just writing to a page?
Here is the code that will write it to the page.


1) from the button click on aspx page (Works)
 public void Button1_Click (object sender, System.EventArgs e)
    {
     Session["name"] = TextBox1.Text;
      Session["email"] = TextBox2.Text;
      Session["DestPage"] = "Finalpage.asp";
      Server.Transfer("ASPXTOASP.aspx");

    }

2) it goes to a "middleman" page ASPXTOASP.aspx (Works)

<script language="C#" runat="server">

private void Page_Load(object sender, EventArgs e){
//We grab all the session variable names/values and stick them in a form
// and then we submit the form to our receiving ASP page (ASPTOASPX.asp)...

Response.Write( "<form name=t id=t action=ASPXTOASP.asp method=post>" );
foreach(object it in Session.Contents)
{
Response.Write("<input type=hidden name=" + it.ToString());
Response.Write( " value=" + Session[it.ToString()].ToString() + " >");
}
if (Request.QueryString["destpage"] !=null)
Response.Write("<input type=hidden name=destpage value=" +Request.QueryString["destpage"].ToString() +">");
Response.Write("</FORM>");
Response.Write("<scr" + "ipt>t.submit();</scr" + "ipt>");
}
</script>



3) Here is the final page. It will write the previously submitted contents to the page.
But I need to have it populate existing textfields.
How can I do this?
<%

Response.Write("This is FinalPage.asp<BR>")
Response.Write "Shared Session Variable Names/Values between ASP.NET and  classic ASP:<BR>"

for each x in Session.Contents
  Response.Write(x & "=" & Session.Contents(x) & "<br />")
next

 

%>
0
Comment
Question by:LT1415
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
Comment Utility
For the "value" atttribute of the existing textfields, do
value='<%= Session.Contents("elementname") %>'

0
 

Author Comment

by:LT1415
Comment Utility
Thanks for your suggestion. No luck on that one
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
Comment Utility
Did you use the appropriate name for "elementname"?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now