AjaxRequestWithTarget MasterPage

11 posts, 0 answers
  1. Michael Finch
    Michael Finch avatar
    16 posts
    Member since:
    May 2008

    Posted 04 Nov 2008 Link to this post

    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,

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 05 Nov 2008 Link to this post

    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.
  3. Michael Finch
    Michael Finch avatar
    16 posts
    Member since:
    May 2008

    Posted 06 Nov 2008 Link to this post

    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?
  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 06 Nov 2008 Link to this post

    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.
  5. Michael Finch
    Michael Finch avatar
    16 posts
    Member since:
    May 2008

    Posted 07 Nov 2008 Link to this post

    Hello Maria,

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

    Thanks
  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Nov 2008 Link to this post

    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.
  7. Sean
    Sean avatar
    19 posts
    Member since:
    Feb 2018

    Posted 19 Nov Link to this post

    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>
  8. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4363 posts

    Posted 19 Nov Link to this post

    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.
  9. Sean
    Sean avatar
    19 posts
    Member since:
    Feb 2018

    Posted 20 Nov Link to this post

    Hello,

    Proxy works!

    Thanks!

  10. Sean
    Sean avatar
    19 posts
    Member since:
    Feb 2018

    Posted 5 days and 1 hour ago Link to this post

    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

     

     

  11. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4363 posts

    Posted 5 days ago Link to this post

    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.
Back to Top