RadWindow - ajax request on parent RadAjaxPanel

8 posts, 1 answers
  1. Mihai
    Mihai avatar
    16 posts
    Member since:
    Oct 2011

    Posted 22 Mar 2013 Link to this post

    Hello,

    I have the following  scenario:

    1. RadWindow on MasterPage
    2. RadAjaxPanel on content page
    3. "closeRadWindow" method in a js file
    4. My guide was this post

    I'm trying to make an ajax request to the radAjaxPanel on the content page when the radWindow is closed.
    So far I came up with the following:

    function closeRadWindow(ajaxPanelID) //ajaxPanelID is the ClientID of the RadAjaxPanel on the content page
    {
    var docum = GetRadWindow().BrowserWindow.document;
    var jqueryAjaxPanel = $(docum).find(ajaxPanelID);
    jqueryAjaxPanel.ajaxRequest("Rebind"); //ERROR HERE GetRadWindow().close();
    }

    The error states something like "object does not have an ajaxRequest method".
    PS:
    - The jqueryAjaxPanel variable is set correctly(jqueryAjaxPanel.html() returns it's html) but it is not of type RadAjaxPanel.
    - I do not want to create a JS function on the content page that will make the ajaxRequest
    Any suggestions? 
    Thank you!

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 25 Mar 2013 Link to this post

    Hello MIhai,

    It seems that the reference you obtain is incorrect because the INamingContainers change the IDs of the controls. I would advise that you create a function in the content page's markup that will return $find("<%=TheDesiredRadAjaxPanel.ClientID%>"); and use that to get the reference to the control in order to use its client-side API. You need the $find() function and not a jQuery wrapper for our control as well.

    Kind regards,
    Marin Bratanov
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mihai
    Mihai avatar
    16 posts
    Member since:
    Oct 2011

    Posted 29 Mar 2013 Link to this post

    I can not use <%# Control.ClientID  %> as I have the function in a JS file, as stated in the initial description.

    I found that the reason why I couldn't call the RadAjaxPanel's ajax request was that I wasn't referencing the RadAjaxPanel in the JS function with it's correct ID.
    Incorrect:  GetRadWindow().BrowserWindow.$find('ajaxpanel').ajaxReqest()
    Correct: GetRadWindow().BrowserWindow.$find('ajaxPanel').ajaxReqest()

    Conclusion: The name of the object is case sensitive.
    PS:  I'm using Static for the ClientIDMode property of the RadAjaxPanel

    Thanks anyway, Marin !
  5. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 29 Mar 2013 Link to this post

    Hello Mihai,

    I would strongly advise against setting ClientIDMode to Static for any RadControl. What you can do is to have a simple getter function in your ASPX markup that will return the desired reference and use that instead of $find() in the JS file. The following blog post can also be useful and shows a similar approach: http://blogs.telerik.com/jefffritz/posts/13-01-21/simplify-javascript-control-references-in-asp.net-webforms.


    All the best,
    Marin Bratanov
    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.
  6. Mihai
    Mihai avatar
    16 posts
    Member since:
    Oct 2011

    Posted 29 Mar 2013 Link to this post

    Hey,

    The idea in the referenced URL is quite nice however mysituation is a bit more complicated(multiple generations of RadWindows opened at the same time, ajax requests not only to parent radWindow but also to parent(ancestor) web form).

    Questions: 
    - Why is it not a good idea to use Static  value for ClientIDMode  property?
    - When should this value be used?

    Thanks
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 02 Apr 2013 Link to this post

    Hello Mihai,

    The framework generates predictive IDs to accommodate for complex pages, e.g. having several instances of a user control on the same page or the more common case - databound controls that need to instantiate many instances of the same template.

    Thus, any container control, especially complex ones (like the RadControls where one is used in another, for example) need to have such dynamically generated IDs to avoid ID duplication and to have proper references. This thread also treats the ClientIDMode question.


    Regards,
    Marin Bratanov
    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.
  8. Samaira
    Samaira avatar
    3 posts
    Member since:
    Nov 2013

    Posted 21 Nov 2013 Link to this post

    Hi,
       I have an aspx page1 which inherits from master page using RadAjaxManager.
    This page1 has two user controls - uc1 & uc2.
    uc1 uses RadAjaxManagerProxy
    uc2 has radWindow
    Now I can use neither RadAjaxManager nor RadAjaxManagerProxy in page1.
    Am calling uc2 on buttton click in page1.
    on button click it loads uc2 which in turn pops up radwindow, but with post back .
    how can I open this uc2(radwindow) with partial postback
  9. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 21 Nov 2013 Link to this post

    Hello Samaira,

    You can open the RadWindow entirely with JavaScript without any postbacks: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html.
    Then, if you need a postback (e.g., to get data for the URL) you should follow this sticky thread on opening a RadWindow from the server: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.
    To use partial postbacks, simply wrap the button that opens the RadWindow in an asp:UpdatePanel with UpdateMode=Conditional. There are other ways as well, but this is perhaps the simplest.


    Regards,
    Marin Bratanov
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017