Hi
I am having a problem with our web app on the search page. My setup is we have a Search.aspx where a RadAjaxManager lives.
From there we have SearchPanel.ascx registered on the search page. This control has its own AjaxEventArgs registered to the OnInit using the Seach.aspx RadManager. This event populates drop down lists with values via an onclick event that is registered to the drop down list control. This works perfectly fine on the first request.
The problem I'm having is when i hit the search button we have registered on that page it fires a seperate AjaxEventArgs with a different AjaxEvent command and it loses the values from the drop down list.
I have undertook the work of upgrading our telerik controls from classic to Asp.Net Ajax control collection (Latest Version) and this previously worked but obviously since I can now only have one manager on the page it seems the behaviour has changed when im hooking up multiple AjaxEventArgs to one manager.
Does this behaviour sound like I have setup any part of the AjaxManager incorrectly or can you point me in any direction I can start looking to resolve this issue? If any more information is required please let me know.
Regards,
Jonathan
I am having a problem with our web app on the search page. My setup is we have a Search.aspx where a RadAjaxManager lives.
From there we have SearchPanel.ascx registered on the search page. This control has its own AjaxEventArgs registered to the OnInit using the Seach.aspx RadManager. This event populates drop down lists with values via an onclick event that is registered to the drop down list control. This works perfectly fine on the first request.
The problem I'm having is when i hit the search button we have registered on that page it fires a seperate AjaxEventArgs with a different AjaxEvent command and it loses the values from the drop down list.
I have undertook the work of upgrading our telerik controls from classic to Asp.Net Ajax control collection (Latest Version) and this previously worked but obviously since I can now only have one manager on the page it seems the behaviour has changed when im hooking up multiple AjaxEventArgs to one manager.
Does this behaviour sound like I have setup any part of the AjaxManager incorrectly or can you point me in any direction I can start looking to resolve this issue? If any more information is required please let me know.
Regards,
Jonathan
5 Answers, 1 is accepted
0
Jonathan
Top achievements
Rank 1
answered on 22 Feb 2012, 04:47 PM
Update
I have discovered that after i hit the search button i lose the values of my dropdown list (Lets call this dropdown list 1) apart from the values of a dropdown list (Lets call this dropdown list 2) that is registered in a different way.
The dropdown list 2 in question has an ajaxRequest associated with it and when i fire that my dropdown list 1 is repopulated.
However, again hitting the search button i lose the values of dropdown list 1 again. The only difference i could spot on dropdown list 2 control is that ViewState is enabled to true and changing this to false was causing me to lose the values of that control as well, after a search button hit.
I thought simply setting viewstate to dropdown list 1 would resolve the problem but the values did not remain.
Can anyone offer any insight into this?
I have discovered that after i hit the search button i lose the values of my dropdown list (Lets call this dropdown list 1) apart from the values of a dropdown list (Lets call this dropdown list 2) that is registered in a different way.
The dropdown list 2 in question has an ajaxRequest associated with it and when i fire that my dropdown list 1 is repopulated.
However, again hitting the search button i lose the values of dropdown list 1 again. The only difference i could spot on dropdown list 2 control is that ViewState is enabled to true and changing this to false was causing me to lose the values of that control as well, after a search button hit.
I thought simply setting viewstate to dropdown list 1 would resolve the problem but the values did not remain.
Can anyone offer any insight into this?
0
Jonathan
Top achievements
Rank 1
answered on 23 Feb 2012, 12:52 PM
Code below - please respond to this request.
Drop List Control
Ajax Request wired up to the current pages ajax manager
Drop List Control
<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="false" CodeBehind="DropDownList.ascx.cs" Inherits="Hexagon.Web.UI.Search.Results.SearchPanelControls.DropDownList" %> <%@ Register TagPrefix="SearchPanelControls" TagName="Label" Src="~/Search2/SearchPanelControls/Label.ascx" %> <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> <script type="text/javascript"> var obj = new SearchField('<%= this.ddl.ClientID %>', '<%= this.ID %>', 'DROPDOWN'); arrSearchInputs.push(obj); </script> </telerik:RadScriptBlock> <SearchPanelControls:Label ID="lbl" ControlType="DROPDOWNLIST" runat="server"></SearchPanelControls:Label> <td class="LeftAligned"> <asp:DropDownList EnableViewState="false" ID="ddl" CssClass="MSBox" AutoPostBack="false" CausesValidation="false" runat="server"></asp:DropDownList> </td>
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Text; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; //BOs using Hexagon.BusinessObjects.Context; using Hexagon.BusinessObjects.Context.User; using Hexagon.BusinessObjects.DocumentManagement.Search; using Hexagon.BusinessObjects.DocumentManagement.Statuses; using Hexagon.BusinessObjects.Context.MilestoneManagement; //Utilities using Hexagon.Utilities.State; //3rd party using Telerik.Web.UI; namespace Hexagon.Web.UI.Search.Results.SearchPanelControls { public partial class DropDownList : SearchPanelControlBase { #region Attributes private SourceType _sourceType = SourceType.UNDEFINED; private string _onChangeJS = string.Empty; #endregion #region Properties public SourceType SourceType { get { return this._sourceType; } set { this._sourceType = value; } } public string OnChangeJS { get { return this._onChangeJS; } set { this._onChangeJS = value; } } #endregion #region Page Life Cycle protected void Page_Load(object sender, EventArgs e) { this.EnableViewState = true; if (!IsPostBack) { this.InitaliseLabel(); if (this._dataSource != null) { this.DataBind(); } else { this.AjaxDataBind(); } } } public void InitialiseAjax(RadAjaxManager radAjaxManager) { radAjaxManager.AjaxSettings.AddAjaxSetting(radAjaxManager, this.ddl); } public void InitialiseAjax(RadAjaxManager radAjaxManager, RadAjaxLoadingPanel RadAjaxLoadingPanel) { radAjaxManager.AjaxSettings.AddAjaxSetting(radAjaxManager, this.ddl, RadAjaxLoadingPanel); } #endregion #region Helpers private void InitaliseLabel() { this.lbl.LabelForClientID = this.ddl.ClientID; this.lbl.ResourceStringsID = this.ID; } public void AjaxDataBind() { if (ddl.Items.Count == 0) { string strAll = this._resourceManager.GetString("all"); this.ddl.Items.Add(new ListItem(strAll, "ALL")); this.ddl.SelectedValue = "ALL"; this.ddl.Attributes.Add("onclick", "SearchPanelAjaxEvent('AJAXDDLLOAD^" + this.ID + "', true);"); } } public override void DataBind() { string strAll = this._resourceManager.GetString("all"); string strCurrentUser = this._resourceManager.GetString("currentUser"); // Added as fix for case : 14829, pratik patel string strCurrentUserOrg = this._resourceManager.GetString("currentUserOrg"); // Added as fix for case : 14829, pratik patel this.ddl.Attributes.Clear(); this.ddl.Items.Clear(); bool bAddCurrentProfileOrg = true; bool bSelected = false; switch (this._sourceType) { case SourceType.ORGANISATION: case SourceType.ORGANISATION_WITHID: #region ORGANISATION if (this._dataSource != null) { int _nearestESPType = ApplicationHelper.CurrentContext.CurrentContainer.Ancestors.NearestESP().ContainerType; foreach (SearchEngine.SearchResultInfo info in (SearchEngine)this._dataSource) { ListItem li = new ListItem(info.Name, _sourceType == SourceType.ORGANISATION ? info.Name.ToString() : info.PrimaryKey.ToString()); li.Attributes.Add("title", ScriptHelper.EscapeJavascript(info.Name)); this.ddl.Items.Add(li); if (info.OrgAtCurrentContext == false && ApplicationHelper.CurrentContext.CurrentContainerType != Utilities.ACLObjectType.ObjectType.ENTERPRISE) { if (ApplicationHelper.CurrentContext.CurrentContainerType == Utilities.ACLObjectType.ObjectType.DOCUMENTFOLDER || ApplicationHelper.CurrentContext.CurrentContainerType == Utilities.ACLObjectType.ObjectType.REVISABLESTATICVIRTUALCONTAINER || ApplicationHelper.CurrentContext.CurrentContainerType == Utilities.ACLObjectType.ObjectType.DYNAMICVIRTUALCONTAINER) { if (_nearestESPType != 2) li.Attributes.Add("class", "GreyedOut"); } else { li.Attributes.Add("class", "GreyedOut"); } } if (info.Name == this._value || info.PrimaryKey.ToString() == this._value) { ddl.SelectedValue = li.Value; bSelected = true; } } } if (bAddCurrentProfileOrg) { ddl.Items.Add(new ListItem(strCurrentUserOrg, "CurrentUserOrg")); // Added as fix for case : 14829, pratik patel if (!bSelected && this._value.ToLower() == "currentuserorg") // Added as fix for case : 14829, pratik patel { ddl.SelectedValue = "CurrentUserOrg"; bSelected = true; } } ddl.Items.Add(new ListItem(strAll, "ALL")); #endregion break; case SourceType.REVISIONSTATUS: #region REVISIONSTATUS if (this._dataSource != null) { foreach (ItemStatusFinder.ItemStatusInfo its in (ItemStatusFinder)this._dataSource) { ListItem li = new ListItem(its.Name, its.ID.ToString()); li.Attributes.Add("title", ScriptHelper.EscapeJavascript(its.Name)); this.ddl.Items.Add(li); if (!its.Assigned) { li.Attributes.Add("class", "GreyedOut"); } if (its.ID.ToString() == this._value) { ddl.SelectedValue = li.Value; bSelected = true; } } } ddl.Items.Add(new ListItem(strAll, "ALL")); #endregion break; case SourceType.PROFILE: #region PROFILE if (this._dataSource != null) { foreach (ROProfile prof in (ProfileFinder)this._dataSource) { // ListItem li = new ListItem(prof.ProfileName, prof.ProfileID.ToString()); ListItem li = new ListItem(prof.UserFriendlyProfileName, prof.ProfileID.ToString()); li.Attributes.Add("title", ScriptHelper.EscapeJavascript(prof.UserFriendlyProfileName)); this.ddl.Items.Add(li); if (prof.ProfileID.ToString() == this._value) { ddl.SelectedValue = li.Value; bSelected = true; } if (prof.IsRevoked) { li.Attributes.Add("class", "Revoked"); } } } if (bAddCurrentProfileOrg) { ddl.Items.Add(new ListItem(strCurrentUser, "currentUser")); // Added as fix for case : 14829, pratik patel if (!bSelected && this._value.ToLower() == "currentuser") // Added as fix for case : 14829, pratik patel { ddl.SelectedValue = "currentUser"; bSelected = true; } } ddl.Items.Add(new ListItem(strAll, "ALL")); #endregion break; case SourceType.READSTATUS: #region READSTATUS if (this._dataSource != null) { int count = 0; foreach (string name in (string[])this._dataSource) { ListItem li = new ListItem(this._resourceManager.GetString(name.ToLower()), name.ToUpper()); li.Attributes.Add("title", ScriptHelper.EscapeJavascript(this._resourceManager.GetString(name.ToLower()))); this.ddl.Items.Add(li); if (this._value != "") { if (count == int.Parse(this._value)) { ddl.SelectedValue = li.Value; bSelected = true; } } count++; } } #endregion break; case SourceType.MILESTONECOMPLETE: if (this._dataSource != null) { int count = 0; foreach (string name in (string[])this._dataSource) { ListItem li = new ListItem(this._resourceManager.GetString(name.ToLower()), name.ToUpper()); li.Attributes.Add("title", ScriptHelper.EscapeJavascript(this._resourceManager.GetString(name.ToLower()))); this.ddl.Items.Add(li); if (this._value != "") { if (count == int.Parse(this._value)) { ddl.SelectedValue = li.Value; bSelected = true; } } count++; } } break; case SourceType.WORKFLOWSTATUS: #region WORKFLOWSTATUS if (this._dataSource != null) { int count = 0; foreach (string name in (string[])this._dataSource) { ListItem li = new ListItem(this._resourceManager.GetString(name.ToLower()), name); li.Attributes.Add("title", ScriptHelper.EscapeJavascript(this._resourceManager.GetString(name.ToLower()))); this.ddl.Items.Add(li); if (this._value != "") { if (count == int.Parse(this._value)) { ddl.SelectedValue = li.Value; bSelected = true; } } count++; } } ddl.Items.Add(new ListItem(strAll, "ALL")); #endregion break; case SourceType.STATE: #region STATE if (this._dataSource != null) { foreach (ListItem li in (ArrayList)this._dataSource) { li.Attributes.Add("title", ScriptHelper.EscapeJavascript(li.Text)); ddl.Items.Add(li); if (li.Value == this._value) { ddl.SelectedValue = li.Value; bSelected = true; } } } ddl.Items.Add(new ListItem(strAll, "ALL")); #endregion break; case SourceType.OVERDUESTATUS: #region OVERDUESTATUS if (this._dataSource != null) { int count = 0; foreach (string name in (string[])this._dataSource) { ListItem li = new ListItem(this._resourceManager.GetString(name.ToLower()), name.ToUpper()); li.Attributes.Add("title", ScriptHelper.EscapeJavascript(this._resourceManager.GetString(name.ToLower()))); this.ddl.Items.Add(li); if (this._value != "") { //if (count == int.Parse(this._value)) if (li.Value.ToLower() == this._value.ToLower()) { ddl.SelectedValue = li.Value; bSelected = true; } } count++; } } ddl.Items.Add(new ListItem(strAll, "ALL")); #endregion break; case SourceType.RECIPIENTTYPE: #region Recipient Type if (this._dataSource != null) { int count = 0; foreach (string name in (string[])this._dataSource) { ListItem li = new ListItem(this._resourceManager.GetString(name.ToLower()), name.ToUpper()); li.Attributes.Add("title", ScriptHelper.EscapeJavascript(this._resourceManager.GetString(name.ToLower()))); this.ddl.Items.Add(li); if (this._value != "") { if (count == int.Parse(this._value)) { ddl.SelectedValue = li.Value; bSelected = true; } } count++; } } ddl.Items.Add(new ListItem(strAll, "ALL")); #endregion break; case SourceType.UNDEFINED: #region UNDEFINED ddl.Items.Add(new ListItem(strAll, "ALL")); #endregion break; } // default selection if (!bSelected) { ddl.SelectedValue = "ALL"; } // onchange js if (_onChangeJS != string.Empty) { ddl.Attributes.Add("onchange", _onChangeJS); } } #endregion } }
Ajax Request wired up to the current pages ajax manager
protected override void OnInit(EventArgs e) { RadAjaxManager manager = RadAjaxManager.GetCurrent(Page); manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(RadAjaxManager0_AjaxRequest); }
protected void RadAjaxManager0_AjaxRequest(object sender, AjaxRequestEventArgs e) { string[] args = e.Argument.Split('^'); switch (args[0]) { case "CLEARITEMPICKER": #region Clear Item Pickers switch (args[1]) { case "SearchIn": SimpleTreeViewHelper.SetCheckedTreeNodes(args[1], new ArrayList()); SimpleTreeViewHelper.SetCheckedTreeNodesToShow(args[1], new ArrayList()); break; } #endregion break; case "REBINDCHILD": #region Rebind Child SearchPanelControls.NestedDropDownList nestedDDL = (SearchPanelControls.NestedDropDownList)this.FindControlRecursive(this.Page, args[1]); // TODO - this should be set depending on the type, only need it because there's no finder nestedDDL.DataSource = MilestoneScheduleDataSource; nestedDDL.RebindChild(args[2]); if (bool.Parse(ConfigurationManager.AppSettings["AjaxifySearchDDls"].ToString())) { this.AjaxDDLLoad("", args[4], bool.Parse(args[3])); } #endregion break; case "SAVESEARCH": #region Save Search this.DoSaveSearch(args[1]); if (bool.Parse(ConfigurationManager.AppSettings["AjaxifySearchDDls"].ToString())) { this.AjaxDDLLoad("", args[2], false); } #endregion break; case "AJAXDDLLOAD": #region Ajax DDL Load this.AjaxDDLLoad(args[1], args[2], false); #endregion break; } }
0
Hi Jonathan,
Could you please let me know if you have an Ajax setting in which the problematic dropdown liast1 is updated by the mentioned search button. If not could you please add such and verify if this makes a difference.
Greetings,
Maria Ilieva
the Telerik team
Could you please let me know if you have an Ajax setting in which the problematic dropdown liast1 is updated by the mentioned search button. If not could you please add such and verify if this makes a difference.
Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jonathan
Top achievements
Rank 1
answered on 24 Feb 2012, 12:23 PM
Hi Maria
Thank you for your reply.
I checked and I did not have an ajax setting for the scenario you mentioned.
I added one and the drop down list still lost its values after the ajax event for the button click.
Regards,
Jonathan
Thank you for your reply.
I checked and I did not have an ajax setting for the scenario you mentioned.
I added one and the drop down list still lost its values after the ajax event for the button click.
Regards,
Jonathan
0
Hi,
From the provided code I noticed that you are populating the problematic DropDown on AjaxRequest in case the search button is clicked. Could you please debug the application locally and verify of the mentioned event is fired and if the code is entering in the needed condition to update the control.
Greetings,
Maria Ilieva
the Telerik team
From the provided code I noticed that you are populating the problematic DropDown on AjaxRequest in case the search button is clicked. Could you please debug the application locally and verify of the mentioned event is fired and if the code is entering in the needed condition to update the control.
Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.