Link to home
Start Free TrialLog in
Avatar of Ramesh Srinivas
Ramesh SrinivasFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Accessing control properties...

I just thought I'd mess around with C# and see what the hell it has to offer and - I feel like a complete newbie!

I don't know whether it is my VS2005 playing around, but I cannot seem to assign any values to control properties.

For example, I get the error on this line:

myLiteral.Text = str.ToString;   //str is a stringbuilder....


The error i get is:

Error      1      An object reference is required for the nonstatic field, method, or property '_Default.myLiteral'      c:\inetpub\wwwroot\c_stream\streaming.aspx.cs      48      9      http://localhost/c_stream/


What is going on!

thanks,

KS
Avatar of shy_talk
shy_talk

At first glance, I'd say you need to call ToString with brackets, as it is a method, not a property.
Avatar of Ramesh Srinivas

ASKER

Yes, that is prob true, but even with brackets I get the same error :(

I cannot seem to reference any controls like this. Works fine when I create a VB.Net project.
When I installed visual studio 2005, I did set the default language option to VB.NET.

Now that I have created a C# project, maybe it has bugged because of some operations occuring during installation??!

Strange!
When I type Literal1.    intellisense does nto show any properties e.g., Text, ID etc etc...

It is doing this for any controls i place on the page.  If I use the word this. then intellisense shows me the name of the control i placed on the page and also its properties. But when I try to compile I get an error:


Error      1      Keyword 'this' is not valid in a static property, static method, or static field initializer      c:\inetpub\wwwroot\c_stream\streaming.aspx.cs      48      9      http://localhost/c_stream/


Damn it.
ASKER CERTIFIED SOLUTION
Avatar of shy_talk
shy_talk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think it was because I was referencing the control from a static method as you mentioned.

A bit confusing seen as tho in vb you can reference a control from a sub function etc etc.

thx.
Not at all - shy