Re: Scope of variables in C# script section of an ASP.NET page

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



ASP.NET application are state less, they open and close in each post back,
so you won't have your variable set in the next time you do apost back.
I don't know if I got your scenario right but I think you need a session. so
you create the instance of your class, put in the values you want then you
put it in the session

"Peter" <spam@xxxxxxxxxxxxxxx> escreveu na mensagem
news:K5Cdnep-d8NNNNDeRVn-hg@xxxxxxxxxxxxxx
> One question that came up is that I am writing an ASP.NET page that has
> some custom (C#) web controls. Since I am not afforded the ability to
> write
> to the console for debugging/information purposes I thought I would simply
> write things to a logfile. Well I instantantiated my custom C# class
> outside
> the page_load function thinking it would only get constructed once and
> then
> get skipped over on refreshes of the IE browser. However apparently there
> seems to be no way around this. Basically I want to have the class as
> global
> class that some of the other C# script functions can access.
>
> My thinking was I could open up a TextWriter in the constructor of the
> global
> class and then close the file in the destructor. My thinking is flawed in
> a couple
> of points. I was thinking that the class would get instantiated once if it
> was outside
> of the page_load and the destructor would kick off if you left the page
> for another
> page. So my new tack is to open the file, insert my messages then quickly
> close
> it back up. Seem reasonable or is it doable to instantiate a class once
> upon
> initially loading of a page and have it available throughout the C#
> script?
>
> BTW, this C# scripting seems to be dissimilar to plain old C#
> applications. I was trying
> to call DateTime.Now but couldn't. Should I have available to me all the
> functions
> that are available in a plain old C# windows application? Are there any
> good reference
> materials on the C# (ASP.NET) scripting particulars that someone could
> recommend?
> Any information would be greatly appreciated!
>
> Thanks,
> Peter
>


.



Relevant Pages

  • Re: JMSs Spotlight at SDCC
    ... Jan of rec.arts.sf.tv.babylon5.moderated make plain: ... If deadlines conspire to gang up on him, the script books can be ... postponed as needed as can Book of Lost Souls, ... To be determined are 'Borrowed Lives'-the script for the pilot is ...
    (rec.arts.sf.tv.babylon5.moderated)
  • Re: Problem with IO::Socket
    ... The PeerPort can be a number or a symbolic service name. ... mention in my first post to keep it scarce and tidy. ... The following script did not run either unless I didn't use use the ... The syntax for the constructor is taken from the docs. ...
    (comp.lang.perl.misc)
  • Manipulating ANY type of email
    ... But what I need to do is to create a function within my script that will add ... Plain Text, has an atachment, whatever. ... #goto CHECKEMAILS; ... sub FetchMailGetMails ...
    (comp.lang.perl.modules)
  • Save the contents of a message to a file.
    ... I really don't know if this is more an entourage question or an applescript ... From there another shell script will ... pick it up and go from there, but the data has to be in plain text. ...
    (microsoft.public.mac.office.entourage)
  • Re: Replacing Adium
    ... Open a *plain* text editor (TextWrangler, ... Paste the script into a *plain* text document. ...
    (comp.sys.mac.apps)