That's the code that i used to put in each aspx page for creation an
instance of class 'test' and that i want to move to the global.asax.
e.g. (before moving it in global.asax)
Partial Class final
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim odescr As New descr
anyvariable = odescr.descrlimit(anyvariable)
.........
It works, but if i remove "Dim odescr As New descr" from here and put it
into glbal.asax, i get the error: 'odescr' is not declared"
"Alexey Smirnov" <> schreef in bericht
news: ups.com...
> On Feb 20, 12:24 am, "michel" <mm@mmm> wrote:
>> Hi Alexey, thanks for replying ...
>> I made the changes but still same error: Name 'odescr' is not declared"
>>
>> global.asax: (unchanged):
>> ----------
>> Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
>> Dim odescr As New test
>> Application.Add("odescr", odescr)
>> End Sub
>>
>> class fle:
>> --------
>> Public Class test
>> Public Function descrlimit(ByVal descr As Object) As String
>> Dim ctx As HttpApplication =
>> HttpContext.Current.ApplicationInstance
>> Dim tmp As String = ctx.Application("odescr").ToString()
>> ....
>> Return tmp
>> End Function
>> End Class
>>
>> "Alexey Smirnov" <alexey.smir...@gmail.com> schreef in
>> berichtnews: ooglegroups.com...
>>
>>
>>
>> > On Feb 19, 11:23 pm, "michel" <mm@mmm> wrote:
>> >> Hi,
>>
>> >> i created a class 'test' with a method 'descrlimit()' (no matter).
>> >> That method is used in a lot of pages in the application, so i need to
>> >> put
>> >> this code a lot of time: "Dim odescr As New test"
>>
>> >> In order to avoid that, i wonder whether it would be possible to put
>> >> that
>> >> line in a central place, like global.asax.
>>
>> >> I tried this:
>>
>> >> class file
>> >> --------
>> >> Public Class test
>> >> Public Function descrlimit(ByVal descr As Object) As String
>> >> Dim tmp As String = descr.ToString()
>> >> ....
>> >> Return tmp
>> >> End Function
>>
>> >> global.asax
>> >> -----------
>> >> Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
>> >> Dim odescr As New test
>> >> Application.Add("odescr", odescr)
>> >> End Sub
>>
>> >> But it generates in all pages which use that method the error: "Name
>> >> 'odescr' is not declared"
>> >> Thanks for helping
>> >> Michel
>>
>> > You've added your variable to the Application object, so you should
>> > refer to it:
>>
>> > Dim ctx as HttpApplication = HttpContext.Current.ApplicationInstance
>> > Dim tmp As String = ctx.Application("odescr").ToString()- Hide quoted
>> > text -
>>
>> - Show quoted text -
>
>
> what's this?
>
> Dim odescr As New test
>
|