0 Replies - 1089 Views - Last Post: 07 January 2014 - 11:52 PM Rate Topic: ***** 1 Votes

#1 aabh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-January 14

Fetch menu item value from <ul><li> menu on Master pag

Posted 07 January 2014 - 11:52 PM

I am trying to read values of drop-down menu item <li ><asp:LinkButton> on 'onclick' event="FetchValues" on the master page to the values on the content page.

I get values one older values than the one that were just clicked. Looks like a page life cycle issue. The "FetchValues" function(on MasterPage) gets processed at the last after the master page and content page load functions run.

How do get the current values and not one previous values.

HTML Code Below




<ul runat="server">
 <li>
 <asp:LinkButton ID="AllMobiles" onclick="FetchValues" 
 runat="server" SkinID="Mobiles" Text="All Mobiles"></asp:LinkButton></li>




I do have ParentLabel and ChildLabel on the master page to display menu item selected

Backend Code Below

Site Master Page


public partial class SiteMaster : System.Web.UI.MasterPage
{
 protected void Page_Load(object sender, EventArgs e)
{
}
 public string FirstValue;
 public String FirstCriteria
{
 get
{
 return FirstValue;
}

}

 public string SecondValue;
 public String SecondCriteria
{
 get
{
 return SecondValue;
}
}
 public String MasterFather

{
 get { return (String)ViewState["masterFather"]; }

 set { ViewState["masterFather"] = value; }
}

 public String MasterChild
{
 get { return (String)ViewState["masterChild"]; }

 set { ViewState["masterChild"] = value; }
}

 public void FetchValues(Object sender, EventArgs e)
{
FirstValue = ((LinkButton)sender).SkinID;
ParentLabel.Text = FirstCriteria;
SecondValue = ((LinkButton)sender).ID;
ChildLabel.Text = SecondCriteria;

this.MasterFather = FirstCriteria;
this.MasterChild = SecondCriteria;

}

}




Content Page Code Below

[code]

protected void Page_Load(object sender, EventArgs e)

{
Father.Text = Master.MasterFather;
Child.Text = Master.MasterChild;

}

I do have <%@ MasterType virtualpath="~/Site.master" %> and labels Father and Child on the Canvas.aspx

Aabh

Is This A Good Question/Topic? 0
  • +

Page 1 of 1