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

AjaxRequestWithTarget MasterPage

10 Answers 132 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Michael Finch
Top achievements
Rank 1
Michael Finch asked on 04 Nov 2008, 04:42 PM

Hi. I have a treeview and am using a context-menu to open a RadWindow. I am then attempting to refresh the treeview in the OnClientClose event of the RadWindow using an ajax call. Everything is working great except for the final client-side ajax call in OnClientClose. It appears to be complaining about the $
in the call 'Main$NavigationTreeView.UniqueID' where Main is the Content ID.

withing the content tag of the webform
<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="Server">

 

 

 

1. My RadAjaxManager declaration in my master page:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ><telerik:AjaxSetting AjaxControlID="Main$NavigationTreeView">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Main$NavigationTreeView" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting

 

 

 

2. Treeview and RadWindow declaration in webform:

<telerik:RadTreeView runat="server" ID="NavigationTreeView" OnContextMenuItemClick="NavigationTreeView_ContextMenuItemClick" ...>
<ContextMenus>
<telerik:RadTreeViewContextMenu ID="MainContextMenu" runat="server">
<Items>
<telerik:RadMenuItem Value="EditNode" Text="Edit node"></telerik:RadMenuItem>
<telerik:RadMenuItem Value="NewNode" Text="New node"></telerik:RadMenuItem> 
<telerik:RadMenuItem Value="DeleteNode" Text="Delete node"></telerik:RadMenuItem>
<telerik:RadMenuItem Value="CopyNode" Text="Copy node" ></telerik:RadMenuItem>
 </Items>
</telerik:RadTreeViewContextMenu>
</ContextMenus>
</telerik:RadTreeView> 

 

 

 

<telerik:RadWindowManager id="Singleton" runat="server">
<windows>
<telerik:RadWindow id="DialogWindow" Behaviors="Close"
OnClientclose = "OnClientClose" Left="250px" Modal = "true" Runat="server" NavigateUrl="./TreeViewDialog.aspx">
</telerik:RadWindow>
</windows>
</telerik:RadWindowManager>

3. Declaration of OnClientClose in webform:

 

<

 

telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript"> 
function OnClientClose(radWindow){
var AJAXMgr = <%= RadAjaxManager.GetCurrent(Page).ClientID %>;
AJAXMgr.AjaxRequestWithTarget(
'<%= Main$NavigationTreeView.UniqueID %>', '');

</script>
</
telerik:RadCodeBlock> 

 

Is this the correct way to do it? What am I doing wrong?

Kind Regards,

10 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 05 Nov 2008, 02:18 PM
Hi Michael,

I reviewed your code and it looks correct.
Could you please let us know what do you mean by "It appears to be complaining about the $"? Does any specific error appear when you run the application? Please elaborate a little bit more on the exact problem you are facing in this scenario, so we could further research and provide accurate solution.

Best wishes,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael Finch
Top achievements
Rank 1
answered on 06 Nov 2008, 01:56 PM

Well, I am trying to reference the control 'NavigationTreeView' in the same page in order to force the postback of the treeview control. I have included the 'Main$' in the reference because that is how AjaxControlID declared in the Master Page. The problem is that when I do this:
    AJAXMgr.AjaxRequestWithTarget('<%= Main$NavigationTreeView.UniqueID %>', '');
I get the error:

 

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1056: Unexpected character '$'

Source Error:

Line 62:      var AJAXMgr = <%= RadAjaxManager.GetCurrent(Page).ClientID %>;
Line 63:      
Line 64: AJAXMgr.AjaxRequestWithTarget('<%= Main$NavigationTreeView.UniqueID %>', '');Line 65: 
Line 66:                 } 

 

 

 


How should I reference this control?
0
Maria Ilieva
Telerik team
answered on 06 Nov 2008, 02:44 PM
Hello Michael Finch,

Only combinations of alphanumeric characters and the underscore character ( _ ) are valid values for this property. the "$" symbol is invalid characters and is causing the ASP.NET page compilation error.

Sincerely yours,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael Finch
Top achievements
Rank 1
answered on 07 Nov 2008, 12:13 PM
Hello Maria,

let's put it another way. How do I reload/ rebind a treeview control using client-side javascript code?

Thanks
0
Maria Ilieva
Telerik team
answered on 07 Nov 2008, 02:57 PM
Hi Michael Finch,

It is not possible to rebind the TreeView with javascript. You could add/remove/edit nodes client-side but not to Rebind the TreeView

All the best,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sean
Top achievements
Rank 1
answered on 19 Nov 2018, 04:00 PM

Hello,

I have similar question. I have my radajaxmanager declared in master page. I was wondering if there is a way i can add ajax setting from an aspx which have master of that page. When no ajaxmanager is declared in master its simple as below but when it is declared, how do i achieve this in markup?

<telerik:RadAjaxManager ID="AjaxManager" runat="server">
  <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="SomeControl">
      <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="SomeOtherControl" LoadingPanelID="SomeLoadingPanel" />
      </UpdatedControls>
     </telerik:AjaxSetting>
  </AjaxSettings>
</telerik:RadAjaxManager>
0
Marin Bratanov
Telerik team
answered on 19 Nov 2018, 06:14 PM
Hello Sean,

If you want declarative settings, use a RadAjaxManagerProxy: https://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/radajaxmanagerproxy/overview.

Note that only controls from the same naming container can be used, so if you want a control on the master page to update a control on the content page, you'll need to add the ajax settings programmatically:

 


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Sean
Top achievements
Rank 1
answered on 20 Nov 2018, 05:03 PM

Hello,

Proxy works!

Thanks!

0
Sean
Top achievements
Rank 1
answered on 04 Dec 2018, 10:33 PM

Hello,

I have a follow up. Using Proxy works fine until i want to make ajaxrequest. I understand that proxy do not have that ability. Moreover i can get ajax manager by doing:

 find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>")

and make ajax request by doing:

find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");

as described here: https://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/radajaxmanagerproxy/overview

but this ajax request is going to master page's code behind. How can i make it to code behind of "this" page? In my specific scenario, i have a GridButtonColumn that opens a radwindow by setting visibleOnPageLoad= true when its CommandName is hit. i need to do 2 things when that radwindow is closed, i need to set visibleOnPageLoad = false AND refresh my page. To open radwindow i need some information from server side so i cannot really use JS "function OnCommand(sender, args) { ... }" as described in this link: https://www.telerik.com/forums/gridbuttoncolumn-client-click-event ... I get as far as on Radwindow  OnClientClose but then i cannot invoke anything on server side AND cannot set visibleOnPageLoad = false . Can you help me out in this last step or some other way i should modify my layout to get desired result. 

Thank you,

Sean

 

 

0
Marin Bratanov
Telerik team
answered on 04 Dec 2018, 10:58 PM
Hi Sean,

See Example 3 in the following page to see how to handle the AjaxRequest server event in the content page: https://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/radajaxmanagerproxy/overview.


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Ajax
Asked by
Michael Finch
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Michael Finch
Top achievements
Rank 1
Sean
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or