i have master page has
<asp:timer id="mastertimer" runat="server" interval="1000" ontick="mastertimer_tick"/> <asp:updatepanel runat="server" id="time" updatemode="always" childrenastriggers="true"> <triggers> <asp:asyncpostbacktrigger controlid="mastertimer" eventname="tick"/> </triggers> <contenttemplate> <asp:label runat="server" id="lbltime"></asp:label> </contenttemplate> </asp:updatepanel>
and in code behind have simple
protected void mastertimer_tick(object sender, eventargs e) { this.lbltime.text = datetime.now.tostring("ddd mmm dd yyyy h:mm:ss tt"); }
in content page have
dictionary<guid, string> data = dataclass.datadictionary();
and creating dynamic server control of label type in default page (content page). server control has property of text. problem is, on each tick read correct data means data dictionary contains updated data , assign label text property not displaying updated text.
i creating customelabel this
customlabel newlabel = new customlabel { text = "label", width = 200, height = 150, }; this.controls.add(newlabel);
and below customlabel class derived linklabel , has below properties
public string text { get; set; } public int width { get; set; } public int height { get; set; }
and
readonly linkbutton label = new linkbutton();
and
protected override void onload(eventargs e) { label.text = text; } protected override void render(htmltextwriter output) { base.render(output); }
i appreciate if tells me need do
this might you:
child page:
<%@ page title="" language="c#" masterpagefile="~/masterpage.master" autoeventwireup="true" codefile="childpage.aspx.cs" inherits="childpage" %> <asp:content id="content1" contentplaceholderid="head" runat="server"> </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <asp:updatepanel id="myupdatepanel" runat="server"> <contenttemplate> <asp:placeholder id="placeholder1" runat="server"></asp:placeholder> </contenttemplate> </asp:updatepanel> </asp:content> public partial class childpage : system.web.ui.page { protected void page_load(object sender, eventargs e) { label newlabel = new label { text = "label", width = 200, height = 150, }; newlabel.text = "label: " + datetime.now.tostring(); placeholder1.controls.add(newlabel); } }
Comments
Post a Comment