Solved

New ASP control not accessible in code behind

Posted on 2006-11-29
5
374 Views
Last Modified: 2012-06-27
Sometimes when I add a new control in ASP it isn't accessible in the codebehind until I completely exit the website and reopen it in Visual Studio 2005.

Here's the latest one:
<asp:ListBox ID="lbStatus" Height="85px" Width="410px" AutoPostBack="false" CausesValidation="false" runat="server" Visible="true"></asp:ListBox>    

It is not available in the list of objects in codebehind.  And when I do "Me.lbStatus" it says it's not a member of my form.

I saved, did a Refresh from the Solution explorer, did a right-click -> refresh on the project name. Nothing works.  What's up with this?
0
Comment
Question by:bozworthy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
stengelj earned 50 total points
ID: 18042660
I run into the same thing from time to time. I think this is some kind of funkiness in the Intellisence.  Here's what I do as a workaround when this happens to me, but I'd love to know if there is a better way.

1. In the .aspx page, set AutoEventWireup="true".
2. Click on a line below the page directed.  Anywhere will do.  It will trigger a refresh of the intellisence.
3. Go to your codebehind page and see if the control is now recognized.
4. If it is, reset the AutoEventWireup setting.
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 18043607
It can sometimes take a while for the Intellisence to recognize a control, but it should not happen to you all the time. I've had it on some occasions, but usually all I needed to do was go on typing and it would recognize it eventually.

Regards,
Max.
0
 
LVL 1

Author Comment

by:bozworthy
ID: 18045327
The wireup trick worked.  That's a reasonable workaround as opposed to closing/opening the entire folder.
0
 
LVL 1

Author Comment

by:bozworthy
ID: 18054870
Actually, just inserting or deleting a blank line in the aspx page works too.
0
 
LVL 9

Expert Comment

by:stengelj
ID: 18055130
Interesting...I guess if I just make it a habit to return after creating a control, this should happen anymore.

Thanks for the shorter workaround!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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