asp.net: ListView on the masterpage -
i have asp.net pages.
i used masterpage implement common control.
there listview on masterpage.
and there label on contentpage.
i want implement below.
when user select node on listview of masterpage,
the label text on contentpage changed text of node.
how can implement this.
could give me advice or link question?
thank in advance.
on master1.master, used itemcommand event on listview
<form id="form1" runat="server"> <asp:listview id="list1" runat="server" onitemcommand="list1_itemcommand"> <itemtemplate> <p> <asp:label id="itemlabel" runat="server" text="<%#container.dataitemindex %>" /> <asp:linkbutton id="itemlink" runat="server" commandname="selectitem" text="select" /> </p> </itemtemplate> </asp:listview> <asp:contentplaceholder id="contentplaceholder1" runat="server"> </asp:contentplaceholder> </form>
and master1.master.cs, store selected item text public property
public partial class master1 : system.web.ui.masterpage { public string selectedtext { get; set; } protected void list1_itemcommand(object sender, listviewcommandeventargs e) { if (e.commandname == "selectitem") { selectedtext = ((label)e.item.findcontrol("itemlabel")).text; } } }
then in content1.aspx , add label id label1
<asp:label id="label1" runat="server" />
finally in conetnt1.aspx.cs, read property "selectedtext" on prerender event (which comes after select click)
protected void page_prerender(object sender, eventargs e) { var mymaster = (master1)this.master; label1.text = mymaster.selectedtext; }
Comments
Post a Comment