Cross page posting with Master page

Discussion in 'ASP .Net' started by =?Utf-8?B?QXR1bCBCYWhs?=, Jul 25, 2005.

  1. 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
     
    =?Utf-8?B?QXR1bCBCYWhs?=, Jul 25, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?QXR1bCBCYWhs?=

    Brock Allen Guest

    What problem are you having?

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > 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
    >
     
    Brock Allen, Jul 25, 2005
    #2
    1. Advertising

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




    "Brock Allen" wrote:

    > What problem are you having?
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > 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
    > >

    >
    >
    >
    >
     
    =?Utf-8?B?QXR1bCBCYWhs?=, Jul 25, 2005
    #3
  4. =?Utf-8?B?QXR1bCBCYWhs?=

    Brock Allen Guest

    I'd suggest not using FindControl and use the strongly typed PreviousPage.
    I posted about this a while back:

    http://staff.develop.com/ballen/blog/PermaLink.aspx?guid=483742fd-01a2-4975-b76c-d3b8b4f29eaf

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > 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
    >
    > "Brock Allen" wrote:
    >
    >> What problem are you having?
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>> 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
    >>>
     
    Brock Allen, Jul 25, 2005
    #4
  5. You should be able to get the value with code like this:

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

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Atul Bahl" <> wrote in message
    news:...
    > 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
    >
    >
    >
    >
    > "Brock Allen" wrote:
    >
    >> What problem are you having?
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>
    >>
    >>
    >> > 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
    >> >

    >>
    >>
    >>
    >>
     
    Steve C. Orr [MVP, MCSD], Jul 25, 2005
    #5
  6. =?Utf-8?B?QXR1bCBCYWhs?=

    jasonkester Guest

    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/
     
    jasonkester, Jul 26, 2005
    #6
  7. =?Utf-8?B?QXR1bCBCYWhs?=

    akaEdge

    Joined:
    Feb 25, 2008
    Messages:
    1
    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
     
    akaEdge, Feb 25, 2008
    #7
  8. =?Utf-8?B?QXR1bCBCYWhs?=

    ExpertPractice

    Joined:
    Jan 14, 2010
    Messages:
    6
    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: Jan 14, 2010
    ExpertPractice, Jan 14, 2010
    #8
  9. =?Utf-8?B?QXR1bCBCYWhs?=

    mohanhegde

    Joined:
    Nov 24, 2010
    Messages:
    1
    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
     
    mohanhegde, Nov 24, 2010
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alan Silver
    Replies:
    4
    Views:
    4,232
    Alan Silver
    Jan 22, 2006
  2. Doug McCann
    Replies:
    1
    Views:
    1,079
    William Brogden
    Aug 5, 2004
  3. =?Utf-8?B?dGhlV2l6YXJkMQ==?=

    Cross Page Posting using public property on previous page

    =?Utf-8?B?dGhlV2l6YXJkMQ==?=, Apr 20, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    720
    Swanand Mokashi
    Apr 20, 2006
  4. Replies:
    1
    Views:
    3,250
    PeterKellner
    May 16, 2006
  5. Replies:
    0
    Views:
    4,164
Loading...

Share This Page