Solved

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

Posted on 2007-11-23
3
2,127 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 500 total points
ID: 20341404
Did you use the appropriate name for "elementname"?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This video teaches users how to migrate an existing Wordpress website to a new domain.

920 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

17 Experts available now in Live!

Get 1:1 Help Now