Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 9th, 2010, 11:31 AM
Registered User
 
Join Date: Apr 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default content page within a master page

Hi,

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 ?

Thanks,
Ran
  #2 (permalink)  
Old April 9th, 2010, 12:27 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old April 9th, 2010, 12:38 PM
Registered User
 
Join Date: Apr 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks,

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.
Thanks,
Ran
  #4 (permalink)  
Old April 9th, 2010, 12:55 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #5 (permalink)  
Old April 9th, 2010, 01:09 PM
Registered User
 
Join Date: Apr 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Thanks,
Ran
  #6 (permalink)  
Old April 9th, 2010, 01:24 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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....

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #7 (permalink)  
Old April 9th, 2010, 01:39 PM
Registered User
 
Join Date: Apr 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Thanks,
Ran
  #8 (permalink)  
Old April 9th, 2010, 01:53 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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:

http://msdn.microsoft.com/en-us/library/ms178581.aspx

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

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #9 (permalink)  
Old April 10th, 2010, 02:23 PM
Registered User
 
Join Date: Apr 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Thanks,

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#
conn.Open();

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

OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.Parameters.Add(parm);

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

cmd.CommandType = CommandType.Text;

OracleDataReader OraRecReader = cmd.ExecuteReader();

CompetenceTestGridView1.DataSource = OraRecReader;

conn.Dispose();
}
  #10 (permalink)  
Old April 10th, 2010, 05:13 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Master Page Method: Code-Behind for Content Page kwilliams ASP.NET 2.0 Professional 3 June 2nd, 2008 12:57 PM
Master Page and Content Page with Java script Harjinder ASP.NET 2.0 Professional 1 February 1st, 2008 10:31 AM
master page and content page interaction mrjoka ASP.NET 2.0 Basics 0 March 15th, 2007 10:45 AM
Access Master page control from Content page. angshujit ASP.NET 2.0 Basics 3 January 11th, 2007 06:20 AM
content page viewstate value in Master Page cbe_seenu ASP.NET 2.0 Professional 0 August 1st, 2006 01:01 AM



All times are GMT -4. The time now is 04:13 AM.


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