Cross Page posting problems asp.net 2.0

B

Bryan

I am trying to get to a label control to get its Text value. from a previous
page.

The label control is buried in a Web User Control that is in a webpart
zone. When I use this code:
foreach(Control c in PreviousPage.Controls)
{
and try to find the control here.

}

I can only see the masterpage, then another loop inside that gets me some
literal controls etc.

I cannot even find the Web Part Zone! Please help, is there an easier way to
do this?

Thanks,
Bryan
 
G

Guest

store the value in the page postback (session, db, etc) and then read it in
on page2.
 
B

Bryan

True, but I was just trying to use the new functionality in 2.0.

If anyone can help using cross page posting using 2.0 that would be great!

Thanks!
Bryan
 
S

Steven Cheng[MSFT]

Hi Bryan,

As for your scenario, the Previous Page's control hierarchy is very
complex, I'd suggest that we first define a public property in the previous
page's page class to expose that certain inner control. for example:

================
public Label InnerLabel
{
get
{
WebPart hw = WebPartZone1.WebParts[0];
UserControl uc = hw.FindControl("HelloWorld1") as UserControl;
Label lbl = uc.FindControl("lblMessage") as Label;

return lbl ;
}
}

==================

then, you can access this propety in the perviouspage instance (through
reflection or strong typed instance) in the target post page's code.

Thanks,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "Bryan" <[email protected]>
| References: <#[email protected]>
<[email protected]>
| Subject: Re: Cross Page posting problems asp.net 2.0
| Date: Thu, 20 Oct 2005 11:55:59 -0700
| Lines: 49
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 208-46-205-150.dia.cust.qwest.net 208.46.205.150
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:132842
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| True, but I was just trying to use the new functionality in 2.0.
|
| If anyone can help using cross page posting using 2.0 that would be great!
|
| Thanks!
| Bryan
|
|
| "Curt_C [MVP]" <software_at_darkfalz.com> wrote in message
| | > store the value in the page postback (session, db, etc) and then read
it
| > in
| > on page2.
| > --
| > Curt Christianson
| > site: http://www.darkfalz.com
| > blog: http://blog.darkfalz.com
| >
| >
| >
| > "Bryan" wrote:
| >
| >> I am trying to get to a label control to get its Text value. from a
| >> previous
| >> page.
| >>
| >> The label control is buried in a Web User Control that is in a
webpart
| >> zone. When I use this code:
| >> foreach(Control c in PreviousPage.Controls)
| >> {
| >> and try to find the control here.
| >>
| >> }
| >>
| >> I can only see the masterpage, then another loop inside that gets me
some
| >> literal controls etc.
| >>
| >> I cannot even find the Web Part Zone! Please help, is there an easier
way
| >> to
| >> do this?
| >>
| >> Thanks,
| >> Bryan
| >>
| >>
| >>
| >>
|
|
|
 
S

Steven Cheng[MSFT]

Hi Bryan,

How are you doing on this issue, does the suggestion in my last reply helps
a little? If there're anything else we can help, please feel free to post
here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: Scott Allen <[email protected]>
| Subject: Re: Cross Page posting problems asp.net 2.0
| Date: Fri, 21 Oct 2005 09:07:02 -0400
| Message-ID: <[email protected]>
| References: <#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| X-Newsreader: Forte Agent 1.8/32.548
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: dyn-170-243-160.myactv.net 24.170.243.160
| Lines: 1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:133006
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Stephen suggestion is good. I also have some additional information
| that shows how to use the strongly typed PreviousPage:
|
| http://odetocode.com/Articles/421.aspx
|
| --
| Scott
| http://www.OdeToCode.com/blogs/scott/
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top