Solved

VS2010 warning help

Posted on 2013-11-13
6
437 Views
Last Modified: 2013-11-13
Getting the warning in my code and not sure how to clean it up properly.
Warning	2	WithEvents variable 'UniqueID' conflicts with property 'UniqueID' in the base class 'Control' and should be declared 'Shadows'.	

Open in new window


This came in shortly after I added
<asp:HiddenField id="UniqueID" runat="server" value=""/> in my default page, and
 If Not IsPostBack = True Then
            Dim GuidString As String = Guid.NewGuid.ToString
            Session("HiddenKeyString") = GuidString
            UniqueID.Value = GuidString
        End If

Open in new window

in my code behind.  I've used this in another project without any additional steps, so I'm unsure why it's causing an issue now.
0
Comment
Question by:sirbounty
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Expert Comment

by:joriszwaenepoel
ID: 39644660
You should change the name because UniqueID is a property for the Control Class in ASP.NET.
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39644676
That's because the control class which is derived by hiddenfield already has a property called uniqueid. Change the id of your hidden field to something else and it will be fine.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 39644698
Consider me a beginner... what do you mean it's a property for the control class?  Have I duplicated something that's embedded natively?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 10

Accepted Solution

by:
joriszwaenepoel earned 125 total points
ID: 39644714
Exactly.

The ASP.NET Page class is a derived class from the Control class, and UniqueID is a property of the Control class.  That means that that property also exists on the Page class.

You added a control to the page, and named it UniqueID also.  Now there is a naming conflict.  

If you give your control a new name, the warning will disappear.
0
 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 125 total points
ID: 39644724
All asp.net controls are derived from the control class, the control class already has a property/attribute called UniqueId.

The control class defines the properties, methods and events shared by all asp.net server controls.

Control Class

UniqueId property of the Control Class
0
 
LVL 67

Author Closing Comment

by:sirbounty
ID: 39644764
And so it did - thanks for the quick help.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question