Reusable Code

Results 1 to 2 of 2

Thread: Reusable Code

  1. #1
    Join Date
    Dec 1969

    Default Reusable Code

    I just started using .NET and am trying to break away from the classic ASP thinking. In classic ASP I used server side include files to maintain re-usable code (i.e. data base connection, etc.).<BR><BR>My ASP.NET app has three pretty similar pages using the exact same data grid, plus I am writing the exact same code to access the database on those pages. Could someone point me to a link or provide insight as to how I would go about creating one database connection and one datagrid to use throughout the site (without hardcoding on each page)?

  2. #2
    Join Date
    Dec 1969

    Default RE: Reusable Code

    It&#039;s probably best to put your connection string in your web.config. Read this....<BR><BR><BR><BR>Also if the datagrid is the same on all 3 pages why not put it into an .ascx file and just reference that in all your pages. You probably should also cache it on the server rather than recreate it every time, unless you expect the chances of a user viewing it in more that one of the pages is small. Personally I think .ascx files are very powerful if used correctly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts