Dynamic Controls, Ajax, and states

4 posts, 0 answers
  1. romulo~
    romulo~ avatar
    23 posts
    Member since:
    Nov 2012

    Posted 26 Feb 2015 Link to this post

    Hello, i have a few questions.
    My scenario is as follows:

    I have a MasterPage with AjaxManager. The content page uses AjaxManagerProxy.
    In the content page, I have a method that loads controls in a panel.
    This method is OK. It loads the controls correctly and i can handle the events inside it normally. The configurations for LoadingPanels also are OK.

    My question is about some behaviors I could not identify, and I don't know if there is something I'm missing with configurations or if the behavior is normal and I should handle it other way.

    The thing is, the control dynamically loaded contains a RadGrid. When I press a button it loads data in this grid.
    Right after that, if I refresh the page (F5) the control is loaded (because of the methods of dynamic loading) but the data on the grid is not there.

    Shouldn't the data be there since the ViewState is enabled? I know there is the event NeedDataSource on the grid, I'm handling it already but maybe i'm not seeing something.

    I realized something too, when pressing F5 it doesn't behaves like a postback, even after I just pressed a button that executed a postback. I mean, normally when I press a button it runs a postback and if I refresh the page it tries the same postback (prompting onthe browser if I want to repeat that) but in this case it doesn't show.

    I would like some help with this. I'll try to shorten the code and post it later.

    Thanks



  2. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 03 Mar 2015 Link to this post

    Hi Romulo,

    Note that when you refresh the page by using the F5 key you are not performing a postback but instead that the page is loaded initially. In such case the ViewState is re-created and none of the previous settings are persisted. So if you populate the data on a button click it is expected the grid to be empty after the page is refreshed by pressing the F5 key.

    Regards,
    Kostadin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. roberto
    roberto avatar
    1 posts
    Member since:
    May 2015

    Posted 27 Oct 2015 Link to this post

    I am dynamically creating controls combobox and texbox using:
    ce = form1.FindControl("cajaDinamico_" + lstDatosComboBoxDinamico[i].sDescripcion.ToLower());
                                 
                                
                              
                               
                               if (ce is Telerik.Web.UI.RadTextBox)
     
                               {
                                      
                                   ((Telerik.Web.UI.RadTextBox)ce).Visible = false;
                                   ((Telerik.Web.UI.RadTextBox)ce).CssClass = "GMMSKIN";
                                   ((Telerik.Web.UI.RadTextBox)ce).AutoPostBack = false;
                                   ((Telerik.Web.UI.RadTextBox)ce).EnableEmbeddedSkins = false;
                                   ((Telerik.Web.UI.RadTextBox)ce).MaxLength = 10;
                                   ((Telerik.Web.UI.RadTextBox)ce).Skin = "GMMSkin";
                                   ((Telerik.Web.UI.RadTextBox)ce).Height = 20;
                                   ((Telerik.Web.UI.RadTextBox)ce).Width = 450;
                                   ((Telerik.Web.UI.RadTextBox)ce).Label = "Suma AseguradaXX " + lstDatosComboBoxDinamico[i].sDescripcion;
                                   ((Telerik.Web.UI.RadTextBox)ce).Text = "NA";
                                   ((Telerik.Web.UI.RadTextBox)ce).ClientEvents.OnKeyPress = "solonumeros";
                               }
                               ce = form1.FindControl("cbDinamico_" + lstDatosComboBoxDinamico[i].sDescripcion.ToLower());
                               if (ce is Telerik.Web.UI.RadComboBox)
                               {
                                   ((Telerik.Web.UI.RadComboBox)ce).Visible = true;
                                   ((Telerik.Web.UI.RadComboBox)ce).AutoPostBack = false;
                                   ((Telerik.Web.UI.RadComboBox)ce).MarkFirstMatch = true;
                                   ((Telerik.Web.UI.RadComboBox)ce).HighlightTemplatedItems = true;
                                   ((Telerik.Web.UI.RadComboBox)ce).EmptyMessage = "SeleccioneXX";
                                   ((Telerik.Web.UI.RadComboBox)ce).NoWrap = true;
                                   ((Telerik.Web.UI.RadComboBox)ce).ItemsPerRequest = 10;
                                   ((Telerik.Web.UI.RadComboBox)ce).EnableVirtualScrolling = true;
                                   ((Telerik.Web.UI.RadComboBox)ce).EnableEmbeddedSkins = false;
                                   //((Telerik.Web.UI.RadComboBox)ce).RegisterWithScriptManager = true;
                                   ((Telerik.Web.UI.RadComboBox)ce).Width = 500;
                                   ((Telerik.Web.UI.RadComboBox)ce).Label = lstDatosComboBoxDinamico[i].sDescripcion.PadRight(dif, '.') + " : ";                               
                                   ((Telerik.Web.UI.RadComboBox)ce).Skin = "GMMSkin";
     
                                   List<ComboBoxCoberEnt> lstDatosCombos = new List<ComboBoxCoberEnt>();
                                   lstDatosCombos = oDatosCombos.CargaValoresCoberturasDinamicas((List<AgrupadorComercialEnt>)ViewState["sListaAgrupador"], ViewState["sMoneda"].ToString(), ViewState["sPlan"].ToString(), lstDatosComboBoxDinamico[i].sDescripcion);
     
                                   ((Telerik.Web.UI.RadComboBox)ce).Items.Clear();
                                   ((Telerik.Web.UI.RadComboBox)ce).DataValueField = "sID";
                                   ((Telerik.Web.UI.RadComboBox)ce).DataTextField = "sDescripcion";
                                   ((Telerik.Web.UI.RadComboBox)ce).DataSource = lstDatosCombos;
                                   //-----Falta el llenado del comobobox dependiente el tipo de cobertura, beneficio
     
                                   ((Telerik.Web.UI.RadComboBox)ce).DataBind();
                               }
                           }
                       }
    But right now I need you to select a value of comobobox "no" or other value , hide the texbox and otherwise show it . But I failed . Can you tell me how to do this .
  5. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 30 Oct 2015 Link to this post

    Hello Roberto,

    Could you please let me know which event you are using to set the visibility and the text/selected item of the controls? Also I noticed that you have declare this controls on the page and you do not create them dynamically on the server. Additionally I prepared a small sample which demonstrates how to select value of the ComboBox and how to set a text of the TextBox.

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top