Cross page posting with Master page

G

Guest

I am not able to reference values by using cross page postings when using
master page.

Currently I am runing on beta 2 of CLR.

Any ideas...

Thanks

Atul
 
G

Guest

Many thanks Brock for responding back, I am actually stuck.

K my problem is that I am using cross page posting from one page to another.
It seems to work fine if I do not use Master page but the moment I use master
page the code reference does not work on the second page.

TextBox textbox1;
textbox1= (TextBox)PreviousPage.FindControl("TextBox1");

on the second page textbox1 shows null with master page.

I do have form tag in master page so I am thinking whether that is the
problem or what is the work around.

Thanks in advance.

Atul
 
S

Steve C. Orr [MVP, MCSD]

You should be able to get the value with code like this:

MyString = Request.Forms("TextBox1").ToString()
 
J

jasonkester

Ah, posts like this always bring a smile to my face.

All I can see is a bright future full of consulting work to clean up
after this new crop of web developers who don't even realize that they
are submitting forms from HTML pages. Yessir, we're set for life,
fellas!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
 
Joined
Feb 25, 2008
Messages
1
Reaction score
0
I had to do this to access my hidden field's value:

Request.Form["ctl00$ContentPlaceHolder1$PassedProductCategoryID"]

OR

Page.PreviousPage.Master.Controls[3].Controls[3].FindControl("PassedProductCategoryID")

which is more ".NET" but still not very good as FindControl isn't recursive so I still needed to use Controls[3] for the Form and the second Controls[3] for the content place holder. Check Rick Strahl's post on recursive FindControl http://www.west-wind.com/WebLog/posts/5127.aspx

I've seen other people just do Master.FindControl("controlName") - but for some reason that never works for me?

Brock's method doesn't work in the situation I have either, as I only do a cross page postback the first time to my page, subsequent times need to stay on the same page.

K. Scott Allen has some good stuff on Masterpages at http://www.odetocode.com/Articles/450.aspx including a bit about cross page postbacks and using the @MasterType directive, I'm going to give it a go
 
Joined
Jan 14, 2010
Messages
6
Reaction score
0
Cross Page Posting while using Master Pages

Hi,
For the users still looking for the solution.

Try this :
///Getting ContentPlaceHolder from the Previous Page
ContentPlaceHolder Holder = (ContentPlaceHolder)Page.PreviousPage.Master.FindControl("ContentPlaceHolder1");
/// Getting Textbox from the ContentPlaceHolder
TextBox tbox= (TextBox) Holder.FindControl("TextBox1");

hope this will help

@li
 
Last edited:
Joined
Nov 24, 2010
Messages
1
Reaction score
0
ExpertPractice said:
Hi,
For the users still looking for the solution.

Try this :
///Getting ContentPlaceHolder from the Previous Page
ContentPlaceHolder Holder = (ContentPlaceHolder)Page.PreviousPage.Master.FindControl("ContentPlaceHolder1");
/// Getting Textbox from the ContentPlaceHolder
TextBox tbox= (TextBox) Holder.FindControl("TextBox1");

hope this will help

@li
Thanks a million buddy!!!

I really broke my head with this particular issue... thought i was the one who was coding it wrong!

Man, i registered to this forum just to say thanks to you... Cheers :D :D
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top