Why this code line doens't work?

S

Shapper

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
 
J

Joe Fawcett

Shapper said:
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.
 
G

Guest

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
 
S

Shapper

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top