Refresh links on master page with data from child page

I have a report links menu on my main page. I need to add an id to the end of each when the user changes the value in the child page. What's a good way to achieve this?

UPDATE: I should have mentioned that updating the child happens inside the UpdatePanel, that is, the master page does not reload when a change occurs.

+1


source to share


2 answers


In response to your UPDATE:

A refreshed panel can write an ID to a hidden field, and menu events can search for hidden fields in Request.Form["fieldName"]

.



Note that you shouldn't fieldName.Text

, because ASP.NET does an unfortunate job of returning the correct value for fields that have been AJAXed.

0


source


MasterPage is truly a child of the page that it controls. You can control MasterPage like any other control on your page (almost). All you have to do is get a link to it.

You add a property to your MasterPage code, so its code might look something like this:

public partial class _default : System.Web.UI.MasterPage
{
    protected string m_myString = string.Empty;
    public string myString
    {
        get { return m_myString; }
        set { m_myString = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

      



Then you need to pass the this.Master property to your MasterPage

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Cast here to get access to your MasterPage
        _default x = (_default)this.Master;
        x.myString = "foo";
    }
}

      

+2


source







All Articles