?
Solved

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

Posted on 2007-11-23
3
Medium Priority
?
2,141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
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.

764 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