Solved

VS2010 warning help

Posted on 2013-11-13
6
434 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now