Object reference across asp:Content boundary

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>
 
M

miher

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
 
G

Gary

I'm unfamiliar with the process of using a "UniqueID" in asp.net. Can you
give me an example?
 
G

Gary

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top