Object reference across asp:Content boundary

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

I have an asp.net 3.5 aspx page that references a site.master file with 3
asp:contentplaceholder sections in it. The main content section contains an
asp:repeater control and it's associated asp:ObjectDataSource. I'd like the
asp:Objectdatasource to be able to reference filter criteria controls in one
of the other asp:content sections.

Is this possible, or do I need to put the control results into the viewstate
and get them from there? Code snippet below reports error that "FilterHeld"
control doesn't exist:

<%@ Page Language="VB" MasterPageFile="~/Site.master" %>
<asp:Content ID="Nav" ContentPlaceHolderID="NavBottom" runat="server">
<asp:CheckBox ID="FilterHeld" runat="server" AutoPostBack="True"
EnableViewState="True" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:ObjectDataSource ID="ObjDS" runat="server"
SelectMethod="GetBLLJobs" TypeName="spJobsBLL">
<SelectParameters>
<asp:ControlParameter ControlID="FilterHeld" DefaultValue="False"
Name="Hold" PropertyName="Checked" Type="Boolean" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:Repeater ID="Rpt1" runat="server" DataSourceID="ObjDS">
<ItemTemplate>
<%#Eval("BatchID")%><br />
</ItemTemplate>
</asp:Repeater>
</asp:Content>
 
Hi,

The contentplaceholders change the name of the controls, so You should use
the UniqueID to reference the control in the ControlID of ControlParameter .

Hope You find this useful.
-Zsolt
 
I'm unfamiliar with the process of using a "UniqueID" in asp.net. Can you
give me an example?
 
In lieu of an answer to this, I have created my textbox elements in the first
content scope, as well label elements in the data results content scope. I'm
now using code-behind event handlers to keep them in sync, which provides the
label.text property to the objectdatasource for filter control.
 
Back
Top