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

issue with Master page and two content pages and getting reference to content page controls

4 Answers 121 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anshul
Top achievements
Rank 1
Anshul asked on 27 Aug 2008, 07:28 PM
Hi,

I have a master page and two content pages for that master page.
The code in the two content pages is almost identical. When I try to setup the Ajax settings in the page load event of the master page, I can get a  reference to the control in one of the content pages but not the other.


Following is the code in the master page code behind: Page_Load

In the following code Grid2 comes back as nothing which is my main issue:

Dim Grid1 As Telerik.Web.UI.RadGrid = CType(Me.ContentPlaceHolder11.FindControl("RadGrid1"), Telerik.Web.UI.RadGrid)

Dim Grid2 As Telerik.Web.UI.RadGrid = CType(Me.ContentPlaceHolder22.FindControl("RadGridPage1"), Telerik.Web.UI.RadGrid)

'Grid2 comes back as nothing

AjaxManager1.AjaxSettings.AddAjaxSetting(RadComboBox1, Grid1,

Nothing)

AjaxManager1.AjaxSettings.AddAjaxSetting(Grid1, RadComboBox2,

Nothing)

AjaxManager1.AjaxSettings.AddAjaxSetting(Grid1, Grid2,

Nothing)



Following is the markup for the Master Page:

<%

@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

<%

@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml">

<

head runat="server">

<title>Untitled Page</title>

<asp:ContentPlaceHolder id="head" runat="server">

</asp:ContentPlaceHolder>

 

<

telerik:RadScriptBlock runat="server" ID="ScriptBlock1">

<

script type="text/javascript">

</

script>

</

telerik:RadScriptBlock>

</

head>

<

body>

<form id="form1" runat="server">

<div>

<div>

<asp:ScriptManager ID="ScriptManager" runat="server" />

<telerik:RadAjaxManager ID="AjaxManager1" runat="server">

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="RadComboBox1">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="RadComboBox1" ></telerik:AjaxUpdatedControl>

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManager>

<telerik:RadAjaxPanel ID="RadAjaxPanelMain" runat="server" EnableAJAX="true">

<telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="true">

<Items>

<telerik:RadComboBoxItem Value="1" Text="One" />

<telerik:RadComboBoxItem Value="2" Text="Two" />

</Items>

</telerik:RadComboBox>

<telerik:RadComboBox ID="RadComboBox2" runat="server" AutoPostBack="true">

<Items>

<telerik:RadComboBoxItem Value="1" Text="One1" />

<telerik:RadComboBoxItem Value="2" Text="Two2" />

</Items>

</telerik:RadComboBox>

<br />

<asp:TextBox ID="Txtfilter" runat="server" onkeyUp="TxtFilterChange(this);" > </asp:TextBox>

</telerik:RadAjaxPanel>

</div>

<telerik:RadAjaxPanel ID="Content1" runat="server" EnableAJAX= "True">

<asp:ContentPlaceHolder id="ContentPlaceHolder11" runat="server">

</asp:ContentPlaceHolder>

</telerik:RadAjaxPanel>

<telerik:RadAjaxPanel ID="Content2" runat="server" EnableAJAX= "True">

<asp:ContentPlaceHolder id="ContentPlaceHolder22" runat="server">

</asp:ContentPlaceHolder>

</telerik:RadAjaxPanel>

<br />

<br />

 

</div>

</form>

</

body>

</

html>

Following is the Markup for the first Content Page:

<%

@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" MasterPageFile="~/MasterPage.master" %>

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

 

<asp:content ID="Content11" contentplaceholderid="ContentPlaceHolder11" runat="server">

Main page

<asp:Panel ID="Panel1" Style="background-color: ButtonFace; width: 100%;" runat="server">

<telerik:RadComboBox ID="RadComboBox1" runat="server">

</telerik:RadComboBox>

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" PageSize="6" PagerStyle-Mode="Slider" ClientSettings-EnablePostBackOnRowClick="true">

<ClientSettings AllowRowsDragDrop="false">

<Selecting AllowRowSelect="True" />

</ClientSettings>

</telerik:RadGrid>

</asp:Panel>

</

asp:content>


Following is the Markup for the second Content page:

<%

@ Page Language="VB" AutoEventWireup="false" CodeFile="DefaultPage2.aspx.vb" Inherits="DefaultPage2" MasterPageFile="~/MasterPage.master" %>

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:content ID="Content22" contentplaceholderid="ContentPlaceHolder22" runat="server">

Main page

<asp:Panel ID="PanelPage1" Style="background-color: ButtonFace; width: 100%;" runat="server">

<telerik:RadComboBox ID="RadComboBoxPage1" runat="server">

</telerik:RadComboBox>

<telerik:RadGrid ID="RadGridPage1" runat="server" AllowPaging="True" PageSize="6" PagerStyle-Mode="Slider" ClientSettings-EnablePostBackOnRowClick="true">

<ClientSettings AllowRowsDragDrop="false">

<Selecting AllowRowSelect="True" />

</ClientSettings>

</telerik:RadGrid>

</asp:Panel>

</

asp:content>

Please let me know if you need more details.

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 28 Aug 2008, 08:26 AM
Hello Anshul,

I reviewed your code snippets and the implementation seems correct - unfortunately I was not able to determine the exact reason for the failure for the second grid on the content page.

Can you please double-check that the ids for the grids passed to the FindControl(id) method match precisely in your configuration? Additionally, consider debugging your code to see whether the Controls collection of the content placeholder from the second content page contains the grid instance (along with the aso Panel and RadComboBox controls).

Alternatively, try the following modification:

Dim Grid1 As Telerik.Web.UI.RadGrid = CType(Me.ContentPlaceHolder11.FindControl("Panel1").FindControl("RadGrid1"), Telerik.Web.UI.RadGrid)   
 
Dim Grid2 As Telerik.Web.UI.RadGrid = CType(Me.ContentPlaceHolder22.FindControl("PanelPage1").FindControl("RadGridPage1"), Telerik.Web.UI.RadGrid)  
 
 

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Anshul
Top achievements
Rank 1
answered on 28 Aug 2008, 02:19 PM
Hi Stephen,

Thanks for your response. I tried your suggestions but no luck.
I dubugged the second contentholder object and the control collection comes up with nothing. I also tried the alternative code lines that you had mentioned but no dice.

One really strange thing also happens sometimes, Grid2 will be found but then Grid1 comes back as nothing.But most of the time Grid2 is the one that comes back as nothing. This is an extremely strange bug, cause as you mentioned I think I have all the markup wired up correctly.

At this point I could attach my project, so you could review it(I am not sure how to do that though).

Basically what I am trying to do is update a master page control from a content page through the Ajaxmanager settings and also through Javascript.
Also I am trying to update controls in other content pages from a child page using the ajaxsettings and javascript. If you do have a working example of this out there that you could point me to that would be great.

again thanks for your help.

Anshul.
0
Sebastian
Telerik team
answered on 29 Aug 2008, 01:10 PM
Hello Anshul,

Does the same problem appear when you attempt to reference the asp panel instance which wrap the two grids and comboboxes? If so, most probably the problem is nested somewhere in your logic and you will need to find out the reason why the content placeholders Controls collection is empty. You may also disable temporary the ajax (EnableAJAX = false for the manager and the ajax panels) and once everything operates as expected re-enable it.

If you are unable to address the problem yourself, isolate a simple version of your project and send it enclosed to a formal support ticket which you can start from your Client.NET account.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Anshul
Top achievements
Rank 1
answered on 29 Aug 2008, 03:59 PM
Hi Stephen,

I've opened up a support ticket with an attached project.

Thanks for your help.

Anshul.
Tags
General Discussions
Asked by
Anshul
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Anshul
Top achievements
Rank 1
Share this question
or