?
Solved

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

Posted on 2007-11-23
3
Medium Priority
?
2,145 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
ID: 20340510
For the "value" atttribute of the existing textfields, do
value='<%= Session.Contents("elementname") %>'

0
 

Author Comment

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

Accepted Solution

by:
Jens Fiederer earned 2000 total points
ID: 20341404
Did you use the appropriate name for "elementname"?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
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…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Suggested Courses

839 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