I'm having trouble rebinding over javascript, and I think its partly cause i'm confused with master pages and their interactions with the ajaxmanager.
RadGrid1 is the id of my RadGrid
RadAjaxMasterManager1 is the id of my RadAjaxManager in the master page
RadAjaxManager1 is the id of my RadAjaxManagerProxy
I'm getting a javascript error of ajaxMgr is null
here is the javascript code that gets called:
My master pages RadAjaxManager is this:
Any hints would be greatly appreciated.
John
RadGrid1 is the id of my RadGrid
RadAjaxMasterManager1 is the id of my RadAjaxManager in the master page
RadAjaxManager1 is the id of my RadAjaxManagerProxy
I'm getting a javascript error of ajaxMgr is null
here is the javascript code that gets called:
function ReloadGrid() |
{ |
var ajaxMgr = $find("<%=RadAjaxManager1.ClientID %>"); |
ajaxMgr.ajaxRequest("RefreshGrid"); |
} |
<telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManagerProxy> |
My master pages RadAjaxManager is this:
telerik:radajaxmanager ID="RadAjaxMasterManager1" runat="server"> |
</telerik:radajaxmanager> |
Any hints would be greatly appreciated.
John
9 Answers, 1 is accepted
0
Hello John,
You can use the static method GetCurrent in order to retrieve the ajax manager in a content page. Here is an example:
var mgr = $find('<%=RadAjaxMasterManager1.GetCurrent(Page).ClientID %>');
mgr.ajaxRequest("RefreshGrid");
You can find more details in this help topic:
http://www.telerik.com/help/radcontrols/prometheus/?ajxAjaxMasterPage.html
Greetings,
Ves
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You can use the static method GetCurrent in order to retrieve the ajax manager in a content page. Here is an example:
var mgr = $find('<%=RadAjaxMasterManager1.GetCurrent(Page).ClientID %>');
mgr.ajaxRequest("RefreshGrid");
You can find more details in this help topic:
http://www.telerik.com/help/radcontrols/prometheus/?ajxAjaxMasterPage.html
Greetings,
Ves
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

John
Top achievements
Rank 1
answered on 28 Mar 2008, 07:05 PM
I'm getting closer, but am still having problems.
I think my issue now is how to wire up the ajaxrequest between the master and content pages.
My master page master manager i've included an onajaxrequest parameter
and in the master code behind I have a blank method to handle this:
Now where in my content page to wire up my delegate?
I tried in my Page_Init but it gives me an object reference not set to an instance of an object error.
How on a master page to a content page (with no user controls) do I do this?
I think my issue now is how to wire up the ajaxrequest between the master and content pages.
My master page master manager i've included an onajaxrequest parameter
<telerik:RadAjaxManager ID="RadAjaxMasterManager1" runat="server" OnAjaxRequest="RadAjaxMasterManager1_AjaxRequest"></telerik:RadAjaxManager> |
and in the master code behind I have a blank method to handle this:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
} |
Now where in my content page to wire up my delegate?
RadAjaxManager.GetCurrent(Page).AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(this.RadAjaxManager1_AjaxRequest); |
I tried in my Page_Init but it gives me an object reference not set to an instance of an object error.
How on a master page to a content page (with no user controls) do I do this?
0

John
Top achievements
Rank 1
answered on 28 Mar 2008, 07:34 PM
I'm trying to do this:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Controls/Examples/Integration/GridAndWindow/DefaultCS.aspx#
but with master pages. Please help!
I'm getting this error
Error: [Exception... "'Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>" data: no]
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Controls/Examples/Integration/GridAndWindow/DefaultCS.aspx#
but with master pages. Please help!
I'm getting this error
Error: [Exception... "'Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>" data: no]
0
Hi John,
Sorry for the misleading info - as it is a static method, it should be like this:
var mgr = $find('<%=RadAjaxManager.GetCurrent(Page).ClientID %>');
mgr.ajaxRequest("RefreshGrid");
Please, find attached a sample page, handling similar functionality. Note, that when using ajaxRequest client-side method, you should configure RadAjaxManager as AJAX initiator control.
As for the error - can you send us an example that we can run locally to reproduce it? Thanks.
All the best,
Ves
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Sorry for the misleading info - as it is a static method, it should be like this:
var mgr = $find('<%=RadAjaxManager.GetCurrent(Page).ClientID %>');
mgr.ajaxRequest("RefreshGrid");
Please, find attached a sample page, handling similar functionality. Note, that when using ajaxRequest client-side method, you should configure RadAjaxManager as AJAX initiator control.
As for the error - can you send us an example that we can run locally to reproduce it? Thanks.
All the best,
Ves
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Chris Ruegsegger
Top achievements
Rank 1
answered on 13 Aug 2008, 03:03 PM
I have been struggling with a similar problem and I wanted to share my solution with others. I hope this helps someone else.
My solution is the result of finding information in about 4 different forum threads, a sample in the code library, and the documentation for the controls. I am using Master Pages and I have a RadGrid on my content page. For each row in the RadGrid, I have a button that opens a window (RadWindowManager). When the window closes, I wanted to do some server-side stuff and rebind the grid.
The main problem was figuring out that RadAjaxManagerProxy does not have a server-side AjaxRequest event like RadAjaxManager. Because I'm using Master Pages and my RadAjaxManager is on the Master Page, I have to use Proxy controls on the content pages. I narrowed down the problem to handling the AjaxRequest event when the window closes. This is how I took care of it.
This code goes on your content page and handles the opening and closing of the window:
This code is also for the content page and handles registering the event handler for the ajaxRequest event:
For your window page, you need this to handle the closing of the window:
And lastly this code on the window page to call the functions above:
EDIT: I also had to add this to the content page:
Chris
My solution is the result of finding information in about 4 different forum threads, a sample in the code library, and the documentation for the controls. I am using Master Pages and I have a RadGrid on my content page. For each row in the RadGrid, I have a button that opens a window (RadWindowManager). When the window closes, I wanted to do some server-side stuff and rebind the grid.
The main problem was figuring out that RadAjaxManagerProxy does not have a server-side AjaxRequest event like RadAjaxManager. Because I'm using Master Pages and my RadAjaxManager is on the Master Page, I have to use Proxy controls on the content pages. I narrowed down the problem to handling the AjaxRequest event when the window closes. This is how I took care of it.
This code goes on your content page and handles the opening and closing of the window:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
<script type="text/javascript"> |
function ShowTransferForm(id, rowIndex) { |
var grid = $find("<%= RadGrid.ClientID %>"); |
var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); |
grid.get_masterTableView().selectItem(rowControl, true); |
window.radopen("TransferAsset.aspx?FixedAssetID=" + id, "TransferAssetDialog"); |
return false; |
} |
function refreshGrid(arg) { |
if (!arg) { |
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Rebind"); |
} |
else { |
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RebindAndNavigate"); |
} |
} |
</script> |
</telerik:RadCodeBlock> |
This code is also for the content page and handles registering the event handler for the ajaxRequest event:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init |
Dim RadAjaxManager1 As RadAjaxManager = DirectCast(Me.Page.Master.FindControl("RadAjaxManager1"), RadAjaxManager) |
Dim handler As New RadAjaxControl.AjaxRequestDelegate(AddressOf Me.RadAjaxManagerProxy1_AjaxRequest) |
AddHandler RadAjaxManager1.AjaxRequest, handler |
End Sub |
Protected Sub RadAjaxManagerProxy1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) |
If e.Argument = "Rebind" Then |
RadGrid.MasterTableView.SortExpressions.Clear() |
RadGrid.MasterTableView.GroupByExpressions.Clear() |
RadGrid.Rebind() |
ElseIf e.Argument = "RebindAndNavigate" Then |
RadGrid.MasterTableView.SortExpressions.Clear() |
RadGrid.MasterTableView.GroupByExpressions.Clear() |
RadGridRadGrid.MasterTableView.CurrentPageIndex = RadGrid.MasterTableView.PageCount - 1 |
RadGrid.Rebind() |
End If |
End Sub |
For your window page, you need this to handle the closing of the window:
<script type="text/javascript"> |
function CloseAndRebind(args) { |
GetRadWindow().Close(); |
GetRadWindow().BrowserWindow.refreshGrid(args); |
} |
function GetRadWindow() { |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well) |
return oWindow; |
} |
function CancelEdit() { |
GetRadWindow().Close(); |
} |
</script> |
And lastly this code on the window page to call the functions above:
Protected Sub btn_Transfer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Transfer.Click |
ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind('navigateToInserted');", True) |
End Sub |
Protected Sub btn_Cancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Cancel.Click |
ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", True) |
End Sub |
EDIT: I also had to add this to the content page:
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender |
Dim RadAjaxManager1 As RadAjaxManagerRadAjaxManager = RadAjaxManager.GetCurrent(Me.Page) |
RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadAjaxManager1, RadGrid) |
End Sub |
Chris
0

Marco
Top achievements
Rank 1
answered on 05 Mar 2009, 05:10 PM
Hello,
I've tried the aforementioned code, including chris', but I am unable to reference the object (System.NullReferenceException) on the line...
$find("<%= RadAjaxManager.GetCurrent(this).ClientID %>").ajaxRequest("Rebind");
I have my RadAjaxManager in the MasterPage, then in the content page I have the RadGrid I want to Ajaxify inside a RadPageView inside a RadMultiPage inside a LoginView.
Any suggestions?
Thanks in advance...
I've tried the aforementioned code, including chris', but I am unable to reference the object (System.NullReferenceException) on the line...
$find("<%= RadAjaxManager.GetCurrent(this).ClientID %>").ajaxRequest("Rebind");
I have my RadAjaxManager in the MasterPage, then in the content page I have the RadGrid I want to Ajaxify inside a RadPageView inside a RadMultiPage inside a LoginView.
Any suggestions?
Thanks in advance...
0

Marco
Top achievements
Rank 1
answered on 06 Mar 2009, 12:52 PM
Nevermind, I had my radajaxmanager before the scriptmanager in my masterpage.
Thanks anyways.
Thanks anyways.
0

Joshua
Top achievements
Rank 1
answered on 25 Jan 2012, 10:20 PM
Unfortunately, the solution you attached called "080709_AJAXMasterPage.zip" is a bad example because the master page needs to be aware that it's "child" page has a control called "Label1".
The example provided by Chris Ruegsegger is a little better, but it requires the child page to know the names of controls on its master page.
How would you do this without the master page containing the child page's logic or without the child page containing knowledge of its master page's control names?
The example provided by Chris Ruegsegger is a little better, but it requires the child page to know the names of controls on its master page.
How would you do this without the master page containing the child page's logic or without the child page containing knowledge of its master page's control names?
0

Gabriel
Top achievements
Rank 1
answered on 02 May 2012, 01:58 PM
Chris Ruegsegger you da man! Been struggling with this problem for three days when I finally stumbled across your solution. Thanks for posting it!