Inside this control a link is displayed. When this link is clicked there should be an Ajax postback. How do I create an event to handle this postback in the code behind of the containing page?
using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
namespace MandateWire.Client { public class ReportSummary : CompositeControl { private string m_TypeOff; private int m_gridIndex; private int m_PensionFundID; private ITemplate m_ItemTemplate;
public int GridIndex { get { return m_gridIndex; } set { m_gridIndex = value; } } public int PensionFundID { get { return m_PensionFundID; } set { m_PensionFundID = value; } } public string TypeOff { get { return m_TypeOff; } set { m_TypeOff = value; } }
[TemplateContainer(typeof(ReportSummary))] [PersistenceMode(PersistenceMode.InnerProperty)] public ITemplate ItemTemplate { get { return m_ItemTemplate; } set { m_ItemTemplate = value; } }
protected override void CreateChildControls() { if (m_ItemTemplate == null) m_ItemTemplate = new ReportSummaryTemplate(); m_ItemTemplate.InstantiateIn(this); } }
public class ReportSummaryTemplate : ITemplate { public void InstantiateIn(Control container) { CreateBackLink(container); }
mark4asp
Member
167 Points
232 Posts
How do I add an event on a page to handle a click on a link inside my server control?
Nov 07, 2008 03:12 PM|LINK
It is declared on a page like so. That page is inside a MasterPage. The control will be inside an UpdatePanel.
Inside this control a link is displayed. When this link is clicked there should be an Ajax postback. How do I create an event to handle this postback in the code behind of the containing page?The code is typically set up like so:
bryce27
Member
298 Points
52 Posts
Re: How do I add an event on a page to handle a click on a link inside my server control?
Nov 07, 2008 07:58 PM|LINK
Hyperlink link= this.Master.FindControl("lnkBack") as Hyperlink;
link.Click += new System.EventHandler(lnkBack_Click);
protected void lnkBack_Click(object sender, EventArgs e)
{
//code here
}
Please Don't forget to click "Mark as Answer" on the post that helped you.