Hello, I have a strange problem. I have a user control, which I'm loading using Dynamic loading using load-control . In this UserControl I have a button on which the OnClick event has been assigned, but when I click on that button, the event is not removed.
& lt;% @ Control language = "C #" AutoEventWireup = "true" CodeBehind = "ServiceInput.ascx.cs" Inheritance = "UP User Control: esericinputs. Service Input" ViewStat Mode = "Disabled"% & gt; & Lt; Div class = "popupfut" & gt; & Lt; ASP: Button ID = "BTNAD" CssClass = "popupadtd" runat = "server" onclic = "btnad_click" /> & Lt; / Div & gt; Protected Zero btnAdd_Click (Object Sender, EventArgs E) {// method is never called: /}
Here I load user control in the page
Protected Zero Service Update Panil_load (Object Sender, EventArggs E) {string arg = Request.Params.Get ("__EvententGUrint"); If (arg == "ServiceInput") {int serviceId; If (enter 32.TryParse (hdnSelectedService.Value, outerviceId)) {(units DB = new organizations ()) {localized service service service = DB. ServiceRecords.OfType & lt; LocalizedServiceRecord & gt; (). FirstOrDefault (s = & gt; s.Id = = servind & amp; s.Language.Id == current language id); LblPopupTitle.Text = service.Name; ServiceInputBase serviceInput = LoadInputControl (service); InputServicePlaceHolder.Controls.Add (serviceInput); ServicesUpdatePanel.Update (); }}}} Private service InputBase Load InputControl (ServiceInputBase ServiceInput = LoadControl ("~ / UserControls / ServiceInputs / ServiceInput.ascx") as ServiceInputBase; Return service input; }
Any ideas?
Now, but maybe someone will find this useful. The problem was that when I got the BtnAdd
, he had a postback and before that he was able to trigger btnAdd_Click
, the user control had already been destroyed.
The solution to this problem is to recreate the usercontrol on postcontrol.
Comments
Post a Comment