Hello I have a weird issue. I have a user control which I load dinamycally using LoadControl. In this UserControl I have a button whith assigned OnClick event, but when I click that button, the event is not fired.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ServiceInput.ascx.cs"
Inherits="uPay.UserControls.ServiceInputs.ServiceInput" ViewStateMode="Disabled" %>
<div class="PopupFoot">
<asp:Button ID="btnAdd" CssClass="PopupADD" runat="server" OnClick="btnAdd_Click" />
</div>
protected void btnAdd_Click(object sender, EventArgs e)
{
//Method never gets called :/
}
Here I load user control in the page
protected void ServicesUpdatePanel_Load(object sender, EventArgs e)
{
string arg = Request.Params.Get("__EVENTARGUMENT");
if (arg == "ServiceInput")
{
int serviceId;
if (Int32.TryParse(hdnSelectedService.Value, out serviceId))
{
using (Entities db = new Entities())
{
LocalizedServiceRecord service = db.ServiceRecords.OfType<LocalizedServiceRecord>().FirstOrDefault(s => s.Id == serviceId && s.Language.Id == CurrentLanguage.Id);
lblPopupTitle.Text = service.Name;
ServiceInputBase serviceInput = LoadInputControl(service);
InputServicePlaceHolder.Controls.Add(serviceInput);
ServicesUpdatePanel.Update();
}
}
}
}
private ServiceInputBase LoadInputControl(ServiceRecord service)
{
ServiceInputBase serviceInput = LoadControl("~/UserControls/ServiceInputs/ServiceInput.ascx") as ServiceInputBase;
return serviceInput;
}
Any Idea?