VS2010 warning help

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.
LVL 67
sirbountyAsked:
Who is Participating?
 
joriszwaenepoelConnect With a Mentor Commented:
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
 
joriszwaenepoelCommented:
You should change the name because UniqueID is a property for the Control Class in ASP.NET.
0
 
Paul JacksonSoftware EngineerCommented:
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
sirbountyAuthor Commented:
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
 
Paul JacksonConnect With a Mentor Software EngineerCommented:
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
 
sirbountyAuthor Commented:
And so it did - thanks for the quick help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.