Using class file as include file of functions...

Results 1 to 2 of 2

Thread: Using class file as include file of functions...

  1. #1
    Join Date
    Dec 1969

    Default Using class file as include file of functions...

    Hi,<BR><BR>I have been trying to sort out the different way you have to &#039;include&#039; files in ASP.NET. What I basically have is a load of commonly used functions that I want in a seperate file.<BR><BR>I searched this form and found a article on 4guysfromrolla called &#039;Accessing Common Code, Constants, and Functions in an ASP.NET Project&#039; which is here:<BR><BR><BR><BR>It explains things fairly well but doesnt tell you how you actually reference the external class file from within your main ASPX page?? I think it assumes you are using visual studio which I am not.<BR><BR>Just to clarify again, its the bit that would go in your ASPX page which in traditional ASP would have looked like this &#039;&#060;!--#include file="includeFile.asp"--&#062;&#039; which references the external file.<BR><BR>Thanks!!<BR><BR>- Carl S

  2. #2
    Join Date
    Dec 1969

    Default RE: Using class file as include file of functions.

    If you have commonly functions that will be used in many different page, I strongly suggest creating a utility class for example.<BR><BR>This class should hold *only* static methods.<BR><BR>You can call static methods without having to instantiate the entire object.<BR><BR>Just like when you use Response.Write<BR>When you do Response then . you notice the intellisence that shows you properties and methods<BR><BR>So you should basically do the same thing.<BR><BR>Create a class called utility inside some namespace.<BR>Then include that namespace in you page<BR><BR>[code language="C#"]<BR>using somenamespace;<BR>[/code]<BR><BR>then simply use it like:<BR>Utilities.xxxx<BR><BR>where Utilities represents the class name<BR>and xxxx the static methods <BR><BR>Hope this helps!<BR>Sincerely<BR><BR>Vlince

Posting Permissions

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