J
John Spiegel
Hi All,
I'm not certain this can be done but it sure seems like it. I'd like to use
multiple C# codebehind files in an aspx page. The idea is that a number of
common functions, like wiring data sources, could be done in a similar
fashion for various controls across multiple pages. What makes sense to me
then would be to have an aspx page that uses a codebehind file. That file
would reference classes in a second file that did the common work.
Assuming I'm on the right track, how would you do this? Is it enough to
simply have both .cs files in the same folder or should each be referenced
in the @Page's Inherits and Src attributes? Basically, I think the idea
should work, but I'm missing the details on referencing and location.
For example, a control:
<aspropDownList id="ddlWidgets" runat="server" />
would be referenced in the codebehind's Page_Load method:
protected void Page_Load( Object Source, EventArgs Args )
{
if (!IsPostBack)
{
WireUpControl( ddlWidgets, "Widgets" );
}
}
where WireUpControl is a method in a class located in a different file that
takes a reference to the control and a table name and binds that table's
data to the control.
TIA,
John
I'm not certain this can be done but it sure seems like it. I'd like to use
multiple C# codebehind files in an aspx page. The idea is that a number of
common functions, like wiring data sources, could be done in a similar
fashion for various controls across multiple pages. What makes sense to me
then would be to have an aspx page that uses a codebehind file. That file
would reference classes in a second file that did the common work.
Assuming I'm on the right track, how would you do this? Is it enough to
simply have both .cs files in the same folder or should each be referenced
in the @Page's Inherits and Src attributes? Basically, I think the idea
should work, but I'm missing the details on referencing and location.
For example, a control:
<aspropDownList id="ddlWidgets" runat="server" />
would be referenced in the codebehind's Page_Load method:
protected void Page_Load( Object Source, EventArgs Args )
{
if (!IsPostBack)
{
WireUpControl( ddlWidgets, "Widgets" );
}
}
where WireUpControl is a method in a class located in a different file that
takes a reference to the control and a table name and binds that table's
data to the control.
TIA,
John