[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2007-11-23
3
Medium Priority
?
2,143 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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
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…
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.

650 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