ASP.NET Custom Controls in code-behind?

HardCode

Freshman
Joined
Apr 2, 2004
Messages
49
I have created a custom control that returns an SqlConnection object. This is in a .ASCX file.

Can I reference this control from inside a .VB code-behind file? Currently, I am referencing it in the .ASPX file via:
Code:
<%@ Register TagPrefix="MyTag" TagName="Ctrl" Src="controls\Connection.ascx" %>

<head>
    <MyTag:Ctrl id="MyConn" runat="Server"></MyTag:Ctrl>
</head>
 
Is that a Connection or a connection string?

Either way I think that it would bettter being in a class instead of a control, unless I'm missing something here.
 
It is a connection object being returned from the custom control. I am still trying to wrap my head around ASP.NET's structure, so I am probably doing something so-very-wrong and missing the obvious. My goal is simply to maintain the connection string to the back-end database in one place. I found info on the Net about using this kind of custom control. That was before I used code-behind. I am now guessing the two don't go together? Should I just make a class that returns a connection object instead? Should I do something else?
 
Back
Top