Thursday, March 22, 2012

Why this code line doens't 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...r />
40872.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)
[url]https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5[/ur
l]
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:
>

0 comments:

Post a Comment