Monday, March 12, 2012

Why this code line doenst work?

Hello,

I have the following code in the Global.asax:

Sub Session_Start(Sender As Object, E As EventArgs)
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
End Sub

The Error I get: "Name 'Thread' is not declared."

However when I have this in my aspx code it works:

Sub Page_Load(Sender As Object, E As EventArgs)
Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT")
End Sub

Why?
Can't I set the culture in the Global.asax?

Thank You,
MiguelHi, Shapper.

Please review these links :

http://www.codingforums.com/archive/index.php/t-10203

http://www.tek-tips.com/faqs.cfm?fid=2707

http://www.eggheadcafe.com/ng/micro...ost20240872.asp

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaol
Ven, y hablemos de ASP.NET...
======================

"Shapper" <mdmoura*NOSPAM*@.gmail.*DELETE2SEND*com> wrote in message
news:u9OpMQLTFHA.3952@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I have the following code in the Global.asax:
> Sub Session_Start(Sender As Object, E As EventArgs)
> Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
> End Sub
> The Error I get: "Name 'Thread' is not declared."
> However when I have this in my aspx code it works:
> Sub Page_Load(Sender As Object, E As EventArgs)
> Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT")
> End Sub
> Why?
> Can't I set the culture in the Global.asax?
> Thank You,
> Miguel
"Shapper" <mdmoura*NOSPAM*@.gmail.*DELETE2SEND*com> wrote in message
news:u9OpMQLTFHA.3952@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I have the following code in the Global.asax:
> Sub Session_Start(Sender As Object, E As EventArgs)
> Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
> End Sub
> The Error I get: "Name 'Thread' is not declared."
> However when I have this in my aspx code it works:
> Sub Page_Load(Sender As Object, E As EventArgs)
> Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT")
> End Sub
> Why?
> Can't I set the culture in the Global.asax?
> Thank You,
> Miguel
Did you Import the System.Threading class? Or use the full name,
System.Threading.Thread.

--

Joe (MVP)

https://mvp.support.microsoft.com/p...E8-8741D22D17A5
My first guess would be that you are missing the namespace of this "Thread"
class or use the complete namespace reference while using "Thread"

Thread class is in System.Threading

"Shapper" wrote:

> Hello,
> I have the following code in the Global.asax:
> Sub Session_Start(Sender As Object, E As EventArgs)
> Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
> End Sub
> The Error I get: "Name 'Thread' is not declared."
> However when I have this in my aspx code it works:
> Sub Page_Load(Sender As Object, E As EventArgs)
> Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT")
> End Sub
> Why?
> Can't I set the culture in the Global.asax?
> Thank You,
> Miguel
>
Ah,

I just found out. I forgot the dam line in Global.asax:
<%@. import Namespace="System.Threading" %
I had it on my ASPX page. I didn't even notice.

Sorry for the time.

Thanks,
Miguel

"Diffident" <Diffident@.discussions.microsoft.com> wrote in message
news:Diffident@.discussions.microsoft.com:

> My first guess would be that you are missing the namespace of this "Thread"
> class or use the complete namespace reference while using "Thread"
> Thread class is in System.Threading
> "Shapper" wrote:
>
> > Hello,
> > I have the following code in the Global.asax:
> > Sub Session_Start(Sender As Object, E As EventArgs)
> > Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
> > End Sub
> > The Error I get: "Name 'Thread' is not declared."
> > However when I have this in my aspx code it works:
> > Sub Page_Load(Sender As Object, E As EventArgs)
> > Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT")
> > End Sub
> > Why?
> > Can't I set the culture in the Global.asax?
> > Thank You,
> > Miguel

0 comments:

Post a Comment