HardCode Posted August 20, 2004 Posted August 20, 2004 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: <%@ Register TagPrefix="MyTag" TagName="Ctrl" Src="controls\Connection.ascx" %> <head> <MyTag:Ctrl id="MyConn" runat="Server"></MyTag:Ctrl> </head> Quote
Moderators Robby Posted August 20, 2004 Moderators Posted August 20, 2004 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. Quote Visit...Bassic Software
HardCode Posted August 20, 2004 Author Posted August 20, 2004 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? Quote
Administrators PlausiblyDamp Posted August 20, 2004 Administrators Posted August 20, 2004 Probably find it easier to store something like a connection string in the web.config file, search these forums and you will find examples of how to do this. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.