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

RadWindow - ajax request on parent RadAjaxPanel

7 Answers 101 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mihai
Top achievements
Rank 1
Mihai asked on 22 Mar 2013, 07:41 AM
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!

7 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 25 Mar 2013, 03:16 PM
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.
0
Mihai
Top achievements
Rank 1
answered on 29 Mar 2013, 07:28 AM
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 !
0
Accepted
Marin Bratanov
Telerik team
answered on 29 Mar 2013, 04:27 PM
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.
0
Mihai
Top achievements
Rank 1
answered on 29 Mar 2013, 05:33 PM
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
0
Marin Bratanov
Telerik team
answered on 02 Apr 2013, 10:25 AM
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.
0
Samaira
Top achievements
Rank 1
answered on 21 Nov 2013, 09:43 AM
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
0
Marin Bratanov
Telerik team
answered on 21 Nov 2013, 12:53 PM
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.
Tags
Window
Asked by
Mihai
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Mihai
Top achievements
Rank 1
Samaira
Top achievements
Rank 1
Share this question
or