p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Professionals (http://p2p.wrox.com/forumdisplay.php?f=352)
-   -   content page within a master page (http://p2p.wrox.com/showthread.php?t=78941)

ran_stb April 9th, 2010 11:31 AM

content page within a master page

I have an issue.

I have a content page within a master page.
When I display the content page by Response.Redirect("content1.aspx");
The values in the text boxes of the master page disappeared.
What should I do ?


Imar April 9th, 2010 12:27 PM

Hi Ran,

This is by design. Response.Redirect instructs the browser to fetch a new page. This means that all state from the current page is lost.

If you explain your scenario in a bit more detail, I may be able to suggest you some solutions.



ran_stb April 9th, 2010 12:38 PM


I'll explain,
I have a master page contains some information reside on some text boxes.
I have also a button on the master page that when I click on it, it redirect the content page to be displayed in the content area of the master page.
The problem is that when I click on the button the content is displayed but the values of the text boxes of the master page are disappeared.
Your advise will be appriciated.

Imar April 9th, 2010 12:55 PM

Yes, I understood that from your initial problem description.

However, it would be useful to know why you want to maintain that text there. E.g. what's it used for, why do you need it, where does it come from and so on.

There are many ways to maintain this data, but the best solution depends on your requirements...


ran_stb April 9th, 2010 01:09 PM

I'll explain,
In the master page I have some info about a person like name, address and so on.
In the content pages I have some additional information about that person, like his driving license details and in the other content pages I have more info like his driving penalties details and so on.
I want to navigate between the content pages without losing the info on the master page.

And one more thing, how can I forward parameters to the content page from the master page, since I have to query some info in the content page from the data base, I have to have the ID of the person for the query, this ID is in the master page and I should use it in the content page.


Imar April 9th, 2010 01:24 PM

You're still not very clear about this.

Where does this data come from? From a database? Did the user just enter it and are you creating a wizard like interface? Do you need to store this only for one or two consecutive pages or must this data be available as long as the user is on the site? Does the data come from the user's profile? Does it need to be persisted between two browser sessions and so on?

You can forward data from one page to another using many different mechanisms, including session state, form state, cookies, query string variables, databases and more. Again, the one you need in this case depends on your scenario. Maybe you need session state, maybe you need to reacrhitecture your pages and use a single page model with, say, a Wizard control. Maybe you need to store the data in the database and rerequest it on each page request. It all depends.

So, be specific, and I can give you a useful answer. Otherwise, we're just going round in circles....



ran_stb April 9th, 2010 01:39 PM

The data in the master page is entered on-line by the user.
I do not create any wizard.
Yes the info have to be available as long as the user is on the site.
I'm using only one browser not two.
The data doesn't come from the user profile, the user enters it on-line.
I just want to navigate between the content pages that reside within the master page without losing the master page information.


Imar April 9th, 2010 01:53 PM

In that case, store data in Session state when it gets submitted, and try setting it again in Page_Load (when Page.PostBack is not true) in the Master Page. For more details:


Out of curiosity, why would you want to store data in the page only during the user's session?


ran_stb April 10th, 2010 02:23 PM

Hi Imar,

Thanks for your help, one more small issue,

I'd like to set a query to a GridView control in order this GridView display the query result.
I do the following but I can not see the gridview,
What should I do, please advise.

protected void Page_Load(object sender, EventArgs e)
string oradb = "Data Source=LOCAL_XE;User Id=tzdl_user;Password=rans;";
OracleConnection conn = new OracleConnection(oradb); // C#

OracleParameter parm = new OracleParameter();
parm.OracleDbType = OracleDbType.Decimal;
parm.Value = 777;

OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;

cmd.CommandText = "select * from competence_test where id_num = :1";

cmd.CommandType = CommandType.Text;

OracleDataReader OraRecReader = cmd.ExecuteReader();

CompetenceTestGridView1.DataSource = OraRecReader;


Imar April 10th, 2010 05:13 PM

You need to call DataBind on the CompetenceTestGridView1 control afrer you've set the DataSource property.

Did you resolve the issue with the form controls and state? If so, would you mind sharing how you solved it?


All times are GMT -4. The time now is 04:41 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.