Re: INCLUDE

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Sorin Dolha [MCSD .NET] (sdolha_at_hotmail.com)
Date: 03/02/04


Date: Tue, 2 Mar 2004 09:48:24 +0200

Dmitri,

Why don't you create a new class (let's call it MyPage) derived from Page, overload the OnLoad() method in MyPage, and then change the base type for every of your web pages' classes to MyPage instead of Page.

This technique is a very common technique for adding common functionality to web pages (it's almost like the master template page concept which will be available in ASP .NET "Whidbey").

-- 
Sorin Dolha [MCAD, MCSD .NET]
  "Dmitri Shvetsov" <dshvetsov@cox.net> wrote in message news:fWU0c.12379$id3.3055@fed1read01...
  Not so easy. I need to do the same steps during ON_LOAD for every asp page.
  That's why I need to insert the same strings to compile them in different
  classes. If I could use an external file and define a static variables etc.,
  it would be a big difference.
  Dmitri.
  "C# Learner" <csharp@learner.here> wrote in message
  news:e6HWFVBAEHA.3256@TK2MSFTNGP09.phx.gbl...
  > Dmitri Shvetsov wrote:
  >
  > > Hi All,
  > >
  > > Does somebody know how can I include an external file into my C# source
  > > file?
  > >
  > > I need to insert the same strings (about 5-10) into about 75 different
  > > files, probably I will need to modify all these strings later, and I see
  it
  > > as a good idea to use an INSERT approach, but C# is not C++ and doesn't
  > > allow me just to insert some external file as I used to do. What's a
  command
  > > for that?
  > >
  > > Thanks,
  > > Dmitri.
  >
  > Create a class in its own file, and add the string constants to it.
  >
  > e.g.:
  >
  > public sealed class StringConstants
  > {
  > // private constructor to stop it getting instantiated
  > private StringConstants()
  > {
  > }
  >
  > public const string One = "One";
  > public const string Two = "Two";
  > }
  >
  > Then later you can use StringConstants.One, etc.


Relevant Pages

  • Re: INCLUDE
    ... class MyBasePage: Page ... Why don't you create a new class (let's call it MyPage) derived from Page, overload the OnLoadmethod in MyPage, and then change the base type for every of your web pages' classes to MyPage instead of Page. ... If I could use an external file and define a static variables etc., ... > Create a class in its own file, and add the string constants to it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need advanced help with tracking down warnings in evald functions
    ... > string (read from an external file). ... > that was being executed when the warning was triggered? ... > Any help with this, pointers to other mailing lists, or alternative ...
    (perl.beginners)
  • Re: using (local) server on SQL 2K
    ... oSheesh, I never thought of putting my conn string in an external file, thanks a lot Chris! ... I also haven't tried the localhost or local URL either, I will try those, THANKS! ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Using FindControl() in global code base
    ... Function MyMethod(TextBoxName as string, MyPage as Page) ... strText = CType, TextBox).Text ... Bin Song, MCP ...
    (microsoft.public.dotnet.framework.aspnet)