Pass a variable from a Master Page to a Content Page

Last post 08-24-2007 7:01 AM by hitinderb4u. 16 replies.

Sort Posts:

  • Re: Pass a variable from a Master Page to a Content Page

    08-24-2007, 3:39 AM

    Hi Chris,

    You want to access the master page's a variable on the content page, right?

    You can store the variable's value in a HiddenField control which represents a hidden field used to store a non-displayed value. You can get the variable's value in the content page by the findcontrol method.

    for example:

    HiddenField hf = (HiddenField)this.Page.Master.FindControl("ctl00$HiddenField1");
            Response.Write(hf.Value);
     hope it helps.
    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Pass a variable from a Master Page to a Content Page

    08-24-2007, 7:01 AM
    • Member
      84 point Member
    • hitinderb4u
    • Member since 08-13-2007, 10:46 AM
    • Bahrain
    • Posts 51

    I have a work around for your problem.

    1)  You can assign the value of variable to a hidden field in master page. And in the load event of content page you can read that value from the field.

     It would go like this:::

    hidden_Label =var

    on contect page :: hidden_label2

    hidden_control2=ctype(me.master.findcontrol("hidden_control"),label)




    if i could get some easy code i will reply.

    Hitinder Bawani

    MCTS - WEB
    ASP.NET
Page 2 of 2 (17 items) < Previous 1 2