0

Hi all,
I am a java programmer and this is the first time I movw to asp .net. However, there is some points i couldnt find out and hopefully i can have some help from you guys.
I have form with is very long so i need to devided it to 6 pages and i want to keep all the values of previous page in cache, until the last page submitted, i will retrieve all the values and submit the form. How to achieve that? I tried Session but it didnt work, I saved one variable in the first page into Session and retrieve it in the second page but it has no value. Somehitng like this:
FIrst page: Sesssion["name"] = "lam"; Second page: string name=(string)Session["name"]; but the variable 'name' has no values.

One other thing is that I wonder if in asp .net we have the option put the whole object to a form. FOr example:

In ex.aspx.cs

class People{
    string firstname;
    string lastname;
//getter and settter
}

In ex.aspx:

<form action="">
<textfield id"people.firstname" runat"server" />
<textfield id"people.lastname" runat"server" />
</form>

Any help please.

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by kad1r
0

First this is wrong

[B]Sesssion[/B]["name"] = "lam";

infact in ASP.NET you would have gotten an Error. If want to create a Session from page1 and Access it in Page2 you have to do this

Page1

Session["MySessionName"] = "Hello World";

and on Page2 you can access the Session that you have created like this

if(Session["MySessionName"] != null)
{  
        String ValueFromPage1 = Convert.ToString(Session["MySessionName"]);
}

That is how Sessions work in ASP.NET

0

And if you want to read session value try this.
string something = Session["your_session"].ToString();

0

I think this is exactly what i have done, it works within one page but for one page to the other page it doesnt. Anyway I found the solution for this issue by using PageView or Wizard form.
But still the second problem is remaining. In java we have a very good tool to map object attributes and fields in a form. And also for database communication, retrieving data directly to objects using Hibernate/JPA, in asp .net it seems that it can just doing things with raw data just like using JDBC in java.
Sorry to distract you but I am quite new here and I wish to have some advices about optimal way to develop web application.

0

But normally when you create a session in one page you can use it all pages in your application. That's why we use sessions.
Maybe you add something in web.config. Like: (in system.web)

<sessionState timeout="1250" />

It's session timeout.

Or I remember something. Is your project in web hosting or localhost? Because some hosting don't allow sessions so you can't access this sessions.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.