I'm loading an user control in one of the class file. This is not code behind page. This is common class for grid view which is applied to all the gridviews in all pages.
I added onclick method to the controls in the user control, but they are not firing in the code behind of that user control.
I kept break points. However, it is not reaching those break points. In addition, the user control is getting closed after I click on any control which has onclick method. After clicking the entire page is reloading in which the grid view is loaded and because of it i guess user control is disappearing. I used update panel in user control still it is not working. Onclicking the the user control is going inside on_pageload of that user control.
This user control is displayed when an image on each column of grid header is clicked. My code is as follows
User control ASCX:
<asp:LinkButton ID="lnkSortDescending" runat="server"
onclick="lnkSortDescending_Click">
Sort Descending
</asp:LinkButton>
Code Behind:
protected void lnkSortDescending_Click(object sender, EventArgs e)
{
//some code
}
File in which user control is loaded:
protected void btnFilterButton_Click(object sender, ImageClickEventArgs e)
{
int i = 0;
Panel p = new Panel();
Control uc = (Control)Page.LoadControl("~/UserControls/FilterPanel.ascx");
uc.ID = "Filter"+(i++);
p.Controls.Add(uc);
}
Please help me to solve this problem.