I am using RadToolTipManager for showing ToolTip for my RadTreeView Nodes. I want to show tooltip for my specific RadTreeView Node not for every Node. Is there anyway that I can achieve with some ajaxrequest so that I can hide my tooltip or show for that node which I would like to show. Any help would be really appreciated.
Protected Sub RadToolTipmanager_AjaxUpdate(ByVal sender As Object, ByVal e As ToolTipUpdateEventArgs)
Dim roleName As String = e.Value
Dim listOfUsersInToolTip As New RadListBox
listOfUsersInToolTip.Width = 150
listOfUsersInToolTip.Height = 200
Dim usersList As ArrayList = rc.GetUserRolesByRoleName(DNN.GetPMB(Me).PortalId, roleName)
If usersList.Count <> 0 Then
For Each user As DotNetNuke.Entities.Users.UserRoleInfo In usersList
listOfUsersInToolTip.Items.Add(New RadListBoxItem(user.FullName, user.UserID))
Next
listOfUsersInToolTip.SortItems()
e.UpdatePanel.ContentTemplateContainer.Controls.Add(listOfUsersInToolTip)
Else
End If
End Sub
9 Answers, 1 is accepted
I already answered your other thread and for your convenience and for others who might encounter the same issue, I pasted my reply below:
Indeed, the RadTreeNodes do not have client IDs. However, you can either assign such on the server or create the tooltip dynamically on the client. For such cases we have prepared the following demo which shows both the approaches:
http://demos.telerik.com/aspnet-ajax/tooltip/examples/tooltiptreeview/defaultcs.aspx
If you want to tooltipify only particular nodes, you should add the only their ClientIDs (which you programmatically set) to the TargetControls collection or create dynamically tooltips only when they are hovered - in this manner the other nodes will not get tooltipified.
Note, also, that if you have ajaxified the sorting, you should make sure that you also update the tooltip manager with AJAX when sorting.
Please, examine the code and use it as a start point for your implementation.
On a side note, when you install RadControls, our online examples projects are automatically installed on your computer and you can not only examine their full source code, but also extend them further in order to meet your requirements.
You can open the demos from here:
Start\Programs\Telerik\RadControls for ASPNET AJAX\Open Sample WebSite In VisualStudio
The actual location on your hard disk is the following one:
C:\Program Files\Telerik\RadControls for ASPNET AJAX \Live Demos
I hope that this information is helpful, let me know if you have additional questions or you need further assistance.
Svetlina
the Telerik team
Exception
System.Web.HttpException was unhandled by user code
ErrorCode=-2147467259
Message=Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Source=System.Web
WebEventCode=0
StackTrace:
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at PS_UserJobMapping.RadToolTipmanager_AjaxUpdate(Object sender, ToolTipUpdateEventArgs e) in C:\inetpub\wwwroot\DNN\DesktopModules\phdcc.CodeModule\PS_UserJobMapping.ascx.vb:line 700
at Telerik.Web.UI.RadToolTipManager.OnAjaxUpdate(ToolTipUpdateEventArgs e)
at Telerik.Web.UI.RadToolTipManager.LoadClientState(Dictionary`2 clientState)
at Telerik.Web.UI.RadWebControl.LoadPostData(String postDataKey, NameValueCollection postCollection)
at Telerik.Web.UI.RadWebControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Protected Sub RadToolTipmanager_AjaxUpdate(ByVal sender As Object, ByVal e As ToolTipUpdateEventArgs)
Dim roleName As String = e.Value
Dim listOfUsersInToolTip As New RadListBox
Dim label As New Label
listOfUsersInToolTip.Width = 150
listOfUsersInToolTip.Height = 200
If IsUserRole(e.Value) Then
Dim usersList As ArrayList = rc.GetUserRolesByRoleName(DNN.GetPMB(Me).PortalId, roleName)
If usersList.Count <> 0 Then
For Each user As DotNetNuke.Entities.Users.UserRoleInfo In usersList
listOfUsersInToolTip.Items.Add(New RadListBoxItem(user.FullName, user.UserID))
Next
listOfUsersInToolTip.Sort = RadListBoxSort.Ascending
listOfUsersInToolTip.SortItems()
RadToolTipManager.Width = "150"
RadToolTipManager.Height = "200"
e.UpdatePanel.ContentTemplateContainer.Controls.Add(listOfUsersInToolTip)
End If
Else
For Each role As RadComboBoxItem In cmbRoleName.Items
If FindUserInRole(role.Text, e.Value) Then
label.Text = e.Value & " belongs to " & role.Text
RadToolTipManager.Width = "160"
RadToolTipManager.Height = "50"
e.UpdatePanel.ContentTemplateContainer.Controls.Add(label)
Exit For
End If
Next
End If
As far as I can see from the code and the error you get a general ViewState error due to loading different control on postback/ajax request.
If you add a control dynamically to a placeholder (update panel in this case) (WebUserControl1.ascx) and on the next postback (ajax request) you add a different control (WebUserControl2.ascx) to the same placeholder ASP.NET tries to load the ViewState of the control contained previously at the placeholder - it's expecting the previous control you added :(WebUserControl1.ascx) but it will encounter another control instead (WebUserControl2.ascx). That is why you get the ViewState problem.
The easiest way to solve this problem is that you set EnableViewState="false" to the RadToolTipManager. The only side effect you can get is in case you set some property on the server and you do this once and not every time, e.g:
if(!isPostBack)
{
RadToolTipManager1.Modal = true;
}
However, since this is not a very often case and you also do not do this in your code, I recommend to set
EnableViewState="false" for the manager.
Let me know whether this works for you.
Svetlina
the Telerik team
As you told me set EnableViewState="false" but now I am getting a new error.
RadToolTipManager response error:
Exception=Sys.WebForms.PageRequestManagerServerErrorException: An error has occurred because a control with id 'dnn$ctr426$View$ctl00$ctl01' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.
I am not completely sure what causes the error but I assume that the problem comes from the fact that you do not set an ID to the control you add and thus it takes automatic ID which seems to be the same for different controls. That is why I suggest to set a unique, different ID to the control before you add it to the tooltip manager panel, e.g similar to this:
listOfUsersInToolTip.ID = Guid.NewGuid().ToString()
e.UpdatePanel.ContentTemplateContainer.Controls.Add(listOfUsersInToolTip)
Svetlina
the Telerik team
I am experiencing the same issue. Setting the EnableViewState="false" property is not working. In my case, for the very first time, the RadTooltipManager_AjaxRequest is called but for successive hovering the issue is displayed.
Regards,
Neerajan Lamsal
Have you tried providing IDs for the controls you add to the RadToolTipManager's update panel? If you need to reload the same user control instead of dynamically generating new instances so that your control can work with postbacks you could try using a static ID. If this does not help please open a support ticket and send us a simple, runnable page that shows your issue so we can help you better.
Best wishes,
Marin
the Telerik team
I have tried every single possible workaround but still getting same error. The code/logic I have implemented is much similar to code mentioned above. Today I tried to add label in front end and tried to change its text as follows:
Protected Sub RadToolTipmanager_AjaxUpdate(ByVal sender As Object, ByVal e As ToolTipUpdateEventArgs)
{
label.EnableViewState= false;
label.Text="Error";
e.UpdatePanel.ContentTemplateContainer.Controls.Add(label);
}
My page is complex to post as it consists of lots of controls and logic. I'm using this control to display the validation Error message which varies upon selection of control. Thanks in advance.
Regards,
Neerajan
There is little more than guessing that I can do for now without being able to examine the issue. What I can suggest is that you create a new literal control each time and place your message there, something like:
Protected
Sub
RadToolTipmanager_AjaxUpdate(
ByVal
sender
As
Object
,
ByVal
e
As
ToolTipUpdateEventArgs)
{
Dim
msg
As
String
=
"your message here, wherever it comes from"
LiteralControl ltrlCtrl = new LiteralControl(msg)
e.UpdatePanel.ContentTemplateContainer.Controls.Add(ltrlCtrl)
}
Your code sample also looks a bit odd and I am not sure how it would compile - a mix between VB.NET and C# would not allow you to run the page. Even if this is some issue with copying I still advise you examine your code for other errors that are masked by the AJAX (i.e. start debugging your page and see where exactly the error is thrown then try to resolve this situation).
Greetings,
Marin
the Telerik team