Welcome to Dream.In.Code
Become an Expert!

Join 150,216 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,118 people online right now. Registration is fast and FREE... Join Now!




Selecting menu item on page load

 
Reply to this topicStart new topic

Selecting menu item on page load

PsychoCoder
8 Nov, 2007 - 07:03 PM
Post #1

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
I don't know if its all the Hydrocodone in this cough medicine the doctor has me on (trying to recover from pneumonia) or what, maybe I'm just a little slow tonight, I'm not sure. In this ASP.Net application I'm working on I'm doing something I know Ive done a thousand times in VB.Net, but for some reason it wont work in C#.

I have made my own tab control using the Menu, MultiView and View controls, and am wanting a certain menu to be selected when the page loads, so I have this:

CODE

protected void Page_Load(object sender, EventArgs e)
{
        if (!IsPostBack)
        {
            Menu1.Items[0].Selected == true;
        }
}


And it gives me this error message:

QUOTE

Only assignment, call, increment, decrement, and new object expressions can be used as a statement


So I thought to myself "Self, maybe you're really just loosing it and you cant actually do this", so before I wrote it off as being stupid on my part I tried it in an ASP.Net app using VB.Net, and viola, worked like a charm. Anyone know why it wont work in C#?
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Selecting Menu Item On Page Load
8 Nov, 2007 - 07:20 PM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,295



Thanked: 18 times
Dream Kudos: 725
My Contributions
This is just a wild guess, but could it be the == you're using to assign the value?
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Selecting Menu Item On Page Load
8 Nov, 2007 - 07:22 PM
Post #3

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
This may sound stupid for asking, but is it because you are using a relational operator and not the assignment operator? One equal sign. Just thought I would ask in case you are not doing a typo.
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Selecting Menu Item On Page Load
8 Nov, 2007 - 07:24 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
OMG! Its the Hydrocodone alright, I never even noticed that I typed that, thanks you 2 LOL
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Selecting Menu Item On Page Load
8 Nov, 2007 - 10:41 PM
Post #5

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Hahaha....happens to the best of us, PsychoCoder. wink2.gif
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Selecting Menu Item On Page Load
9 Nov, 2007 - 05:50 AM
Post #6

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
jayman I was talking to Chris on Pidgen last night when trying to figure out this problem, he was laughing at me, then Marty and girasquid find my problem, which made me feel like a total n00b LOL
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 05:26AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month