This is a migrated thread and some comments may be shown as answers.

PostBack from UserControl as custom edit form

3 Answers 171 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adrian
Top achievements
Rank 1
Adrian asked on 15 Jun 2009, 10:35 AM
Hi!
I have my control with CheckBox <- this is my problem. I want to show panel when CheckBox is checked.
My control is used like this:

<EditFormSettings UserControlName="../UserControls/Process/StateAlert.ascx" EditFormType="WebUserControl"
     <EditColumn UniqueName="EditCommandColumn1"
     </EditColumn> 
</EditFormSettings>  

Inside control I have property:

public object DataItem 
        { 
            get 
            { 
                return dataItem; 
            } 
            set 
            { 
                if (value != null
                { 
                    if (value is StateJobTemplate) 
                    { 
                        StateJobTemplate template = (StateJobTemplate)value; 
                        ShowControl(true, (StateJobTypes)template.StateJobType, template); 
                        _sjtItem = template; 
                    } 
                    else 
                    { 
                        Telerik.Web.UI.GridInsertionObject newAlert = (Telerik.Web.UI.GridInsertionObject)value; 
                        StateJobTemplate template = newAlert.GetPropertyValue("JobTemplate"as StateJobTemplate; 
                        ShowControl(true, (StateJobTypes)template.StateJobType, template); 
                        _sjtItem = template; 
                    } 
                    btnCancel.Visible = true
                } 
                dataItem = value; 
            } 
        }  


Now, when I checked CheckBox, RadGrid and my control inside disappear.
If I place CheckBox inside UpdatePanel or AjaxPanel, I'll have fallowing error:

 
Sys.WebForms.PageRequestManagerServerErrorException: Nie mo|na wyrejestrowa elementu UpdatePanel o identyfikatorze uPanelDelay, poniewa| nie zostaB on zarejestrowany w elemencie ScriptManager. Ta sytuacja mo|e wystpi, je[li element UpdatePanel zostaB usunity z drzewa formantów, a nastpnie dodany ponownie, co nie jest obsBugiwan operacj. 
Nazwa parametru: updatePanel' when calling method: [nsIDOMEventListener::handleEvent]"  nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)"  location: "JS frame :: chrome://firebug/content/spy.js :: onHTTPSpyReadyStateChange :: line 497"  data: no] 
http://localhost:9920/ScriptResource.axd?d=1B-MRZCEFwolhXDsshMf4JjZOQs3iq1lzhqE6bwgKqGK8lEWWx8KGThf_Rfugcg6TbxwknueZdk1ek5e3cT_FYN0GGs0HIzmvczdBTv9-1E1&t=ffffffff91beb05b Line 5 

It's in Polish so I'll try to explain. Error says that UpdatePanel can't be unregistered because it wasn't registered in ScriptManager.
Please, help ;)

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 17 Jun 2009, 02:10 PM
Hello Adrian,

Here is a test project which I have created in order to reproduce the described error. Please fidn the attached .zip file and examine it. Let me know if I am missing something.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
0
Adrian
Top achievements
Rank 1
answered on 17 Jun 2009, 07:39 PM

Thanks for program.

In the meantime I did this by JavaScript without PostBack but i downloaded zip for a later time ;)

0
Adrian
Top achievements
Rank 1
answered on 18 Nov 2009, 02:55 PM

Hello again. 

This time i can't use JavaScript, but now i know more.

The problem is caused by my control in which RadGrid is. When RadGrid is outside everything is fine.

Same pice of code of this control:

 public class ItemEditCtrl : CompositeControl, INamingContainer  
{  
 private ITemplate _contentTemplate;  
        [PersistenceMode(PersistenceMode.InnerProperty)]  
        [TemplateInstance(TemplateInstance.Single)]  
        [MergableProperty(false)]  
        [Browsable(false)]  
        [TemplateContainer(typeof(ItemEditCtrl))]  
        public ITemplate ContentTemplate  
        {  
            get { return _contentTemplate; }  
            set { _contentTemplate = value; }  
        }  
...  
        protected override void OnLoad(EventArgs e)  
        {  
            this.EnsureChildControls();  
            base.OnLoad(e);  
            ...  
        }  
        public override ControlCollection Controls  
        {  
            get  
            {  
                this.EnsureChildControls();  
                return base.Controls;  
            }  
        }  
protected override void OnPreRender(EventArgs e)  
        {  
            this.EnsureChildControls();  
 
            base.OnPreRender(e);  
            btSave.Text = TranslationEngine.GetTxt(SaveCommand);  
            btSave.ValidationGroup = ValidationGroup;  
            btSave.Visible = SaveVisible;  
            btClose.CausesValidation = false;  
            this.ValidationGroup = string.Empty;  
 
            wrapper.Style["top"] = Position.Y.ToString() + "px";  
            wrapper.Style["left"] = Position.X.ToString() + "px";  
 
            wrapper.Style["display"] = StringDisplayStyle;  
            background.Style["display"] = StringDisplayStyle;  
 
            if (this.Visible)  
            {  
                PrepareValidatorsScriptsInvoker();  
                  
                ...  
                  
                this.DataBind();  
            }  
        }  
...  
protected override void OnInit(EventArgs e)  
        {  
            this.EnsureChildControls();  
            base.OnInit(e);  
        }  
 
protected override void CreateChildControls()  
        {  
            background = new HtmlGenericControl("div");  
            background.Attributes["class"] = "modalBack";  
            background.ID = "modalBack";  
            Controls.Add(background);  
 
            wrapper = new Panel();  
            if (Width.IsEmpty || WindowWidth > 0)  
            {  
                wrapper.Attributes["style"] = string.Format("width:{0}px;", WindowWidth);   
            }   
            else  
                wrapper.Style["width"] = Width.ToString();  
 
            if(!Height.IsEmpty)  
                wrapper.Style["height"] = Height.ToString();  
 
            wrapper.Attributes["class"] = "modalWnd";  
              
              
           // wrapper.Attributes["style"] = string.Format("width:{0}px;", WindowWidth);  
 
            wrapper.ID = "editPopup";  
            Controls.Add(wrapper);  
 
            head = new HtmlGenericControl("div");  
            head.ID = "editPopupHead";  
            head.Attributes["class"] = "modalHead";  
            //head.Attributes["style"] = string.Format("width:{0}px;", WindowWidth);  
 
            wrapper.Controls.Add(head);  
 
            btClose = new System.Web.UI.WebControls.Button();  
            btClose.Text = TranslationEngine.GetTxt("Close");  
            btClose.OnClientClick = string.Format("$get('{0}').style.display='none';$get('{1}').style.display='none';", wrapper.ClientID, background.ClientID);  
            btClose.Click += new EventHandler(btClose_Click);  
            btClose.CausesValidation = false;  
            btClose.CssClass = "button_close";  
 
            head.Controls.Add(btClose);  
 
            content = new Panel();  
            content.ID = "content";  
            content.Style["overflow-y"] = "auto";  
            content.Height = Unit.Pixel(Math.Max(40, (int)Height.Value) - 40);  
            if (content.Height.Value == 0)  
                content.Height = Unit.Percentage(100);  
            wrapper.Controls.Add(content);  
 
            ContentTemplate.InstantiateIn(content);  
 
            position = new HtmlInputHidden();  
            position.ID = "position";  
            wrapper.Controls.Add(position);  
 
            btSave = new Button();  
            btSave.Click += new EventHandler(btSave_Click);  
            btSave.ValidationGroup = "selectorVG";  
            btSave.CssClass = "button_blue";  
 
            wrapper.Controls.Add(btSave);  
 
            wrapper.DefaultButton = btSave.ID;  
 
            this.ChildControlsCreated = true;  
 
        }  
...  
Someone can help me? What is wrong with this control?

Tags
Grid
Asked by
Adrian
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Adrian
Top achievements
Rank 1
Share this question
or