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

Dynamic Controls, Ajax, and states

3 Answers 24 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
romulo~
Top achievements
Rank 1
romulo~ asked on 26 Feb 2015, 01:48 PM
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



3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 03 Mar 2015, 12:47 PM
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.

 
0
roberto
Top achievements
Rank 1
answered on 27 Oct 2015, 09:26 PM
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 .
0
Kostadin
Telerik team
answered on 30 Oct 2015, 09:14 AM
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
Tags
Ajax
Asked by
romulo~
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
roberto
Top achievements
Rank 1
Share this question
or