Solved

New ASP control not accessible in code behind

Posted on 2006-11-29
5
367 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

18 Experts available now in Live!

Get 1:1 Help Now