Where do I put user changeable parameters now in 2.0? (global.asax)

Discussion in 'ASP .Net' started by gordonfmoore@yahoo.co.uk, Dec 8, 2005.

  1. Guest

    Hi,

    for some reason? I learnt it was sensible/useful to put any parameters
    that I wanted users to be able to change in the global.asax file.

    So my code would look like:

    //in my page load
    protected void Page_Load(object sender, System.EventArgs e)
    {
    myLabel.Text = (string) Application["PageHeading"];
    string mydbfile = (string) Application["MDBDefault"];
    string myLinkToUrl = (string) Application["DefaultWebpage"];
    }

    //in my global.asax file
    <script language = "c#" runat="server">

    protected void Application_OnStart()
    {
    Application["PageHeading"] = "Maths Production (2.0)";
    Application["DefaultWebpage"] = "http://intranet";
    Application["MDBDefault"] = "App_Data/YAS.mdb";
    }
    </script>

    This worked well under .net 1.1 with precompiled aspx.cs files (as a
    dll)

    However, they've done it to me again and now I have to fix what wasn't
    broken under 2.0

    If I use the (afterthought) web deployment projects add in, I can
    compile my codebehind, but it also compiles my global.asax and so my
    customers can't set up the system parameters as they want to.

    So how do I now do this? Please. (I'm not really hacked off - honest!
    :( )

    Regards

    Gordon
     
    , Dec 8, 2005
    #1
    1. Advertising

  2. Karl Seguin Guest

    All these "configuration" values should either be database driven (if they
    need to be managed through an interface) or simply in the web.config. This
    is likely the best way in both 1.x and 2.x.

    You can either simply use the AppSettings section, or write your own
    configuration handler and have a little section to yourself:
    http://openmymind.net/index.aspx?documentId=5

    Karl
    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    <> wrote in message
    news:...
    > Hi,
    >
    > for some reason? I learnt it was sensible/useful to put any parameters
    > that I wanted users to be able to change in the global.asax file.
    >
    > So my code would look like:
    >
    > //in my page load
    > protected void Page_Load(object sender, System.EventArgs e)
    > {
    > myLabel.Text = (string) Application["PageHeading"];
    > string mydbfile = (string) Application["MDBDefault"];
    > string myLinkToUrl = (string) Application["DefaultWebpage"];
    > }
    >
    > //in my global.asax file
    > <script language = "c#" runat="server">
    >
    > protected void Application_OnStart()
    > {
    > Application["PageHeading"] = "Maths Production (2.0)";
    > Application["DefaultWebpage"] = "http://intranet";
    > Application["MDBDefault"] = "App_Data/YAS.mdb";
    > }
    > </script>
    >
    > This worked well under .net 1.1 with precompiled aspx.cs files (as a
    > dll)
    >
    > However, they've done it to me again and now I have to fix what wasn't
    > broken under 2.0
    >
    > If I use the (afterthought) web deployment projects add in, I can
    > compile my codebehind, but it also compiles my global.asax and so my
    > customers can't set up the system parameters as they want to.
    >
    > So how do I now do this? Please. (I'm not really hacked off - honest!
    > :( )
    >
    > Regards
    >
    > Gordon
    >
     
    Karl Seguin, Dec 8, 2005
    #2
    1. Advertising

  3. clintonG Guest

    Hey Gordon, read these [1],[2] and if I might nitpick shouldn't your
    parameters be written using camel case, i.e. pageHeading and so on?

    <%= Clinton Gallagher
    METROmilwaukee (sm) "A Regional Information Service"
    NET csgallagher AT metromilwaukee.com
    URL http://metromilwaukee.com/
    URL http://clintongallagher.metromilwaukee.com/


    [1] http://msdn2.microsoft.com/library/2y3fs9xs(en-us,vs.80).aspx
    [2]
    http://msdn.microsoft.com/asp.net/c...l=/library/en-us/dnvs05/html/userprofiles.asp



    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    wrote in message news:upAHwHF$...
    > All these "configuration" values should either be database driven (if they
    > need to be managed through an interface) or simply in the web.config.
    > This is likely the best way in both 1.x and 2.x.
    >
    > You can either simply use the AppSettings section, or write your own
    > configuration handler and have a little section to yourself:
    > http://openmymind.net/index.aspx?documentId=5
    >
    > Karl
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    > http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    >
    >
    >
    > <> wrote in message
    > news:...
    >> Hi,
    >>
    >> for some reason? I learnt it was sensible/useful to put any parameters
    >> that I wanted users to be able to change in the global.asax file.
    >>
    >> So my code would look like:
    >>
    >> //in my page load
    >> protected void Page_Load(object sender, System.EventArgs e)
    >> {
    >> myLabel.Text = (string) Application["PageHeading"];
    >> string mydbfile = (string) Application["MDBDefault"];
    >> string myLinkToUrl = (string) Application["DefaultWebpage"];
    >> }
    >>
    >> //in my global.asax file
    >> <script language = "c#" runat="server">
    >>
    >> protected void Application_OnStart()
    >> {
    >> Application["PageHeading"] = "Maths Production (2.0)";
    >> Application["DefaultWebpage"] = "http://intranet";
    >> Application["MDBDefault"] = "App_Data/YAS.mdb";
    >> }
    >> </script>
    >>
    >> This worked well under .net 1.1 with precompiled aspx.cs files (as a
    >> dll)
    >>
    >> However, they've done it to me again and now I have to fix what wasn't
    >> broken under 2.0
    >>
    >> If I use the (afterthought) web deployment projects add in, I can
    >> compile my codebehind, but it also compiles my global.asax and so my
    >> customers can't set up the system parameters as they want to.
    >>
    >> So how do I now do this? Please. (I'm not really hacked off - honest!
    >> :( )
    >>
    >> Regards
    >>
    >> Gordon
    >>

    >
    >
     
    clintonG, Dec 9, 2005
    #3
  4. Guest

    Thanks guys, that helped. I hadn't realised that web.config could be
    used for this.

    Clinton, you are probably right :)
     
    , Dec 10, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?YmNoYXJsZXM=?=

    global.asax and global.asax.cs

    =?Utf-8?B?YmNoYXJsZXM=?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    914
    =?Utf-8?B?YmNoYXJsZXM=?=
    Oct 5, 2004
  2. Mark Rae

    Global.asax / Global.asax.cs in v2

    Mark Rae, May 23, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    3,211
    Mark Rae
    May 23, 2006
  3. OK
    Replies:
    5
    Views:
    642
    Peter Bromberg [C# MVP]
    Nov 26, 2007
  4. Treetop

    Picture and text changeable on a page

    Treetop, Jan 14, 2004, in forum: Javascript
    Replies:
    0
    Views:
    81
    Treetop
    Jan 14, 2004
  5. Tim Green

    User-changeable colours

    Tim Green, Jun 19, 2005, in forum: Javascript
    Replies:
    4
    Views:
    88
    Tim Green
    Jun 21, 2005
Loading...

Share This Page