Solved

New ASP control not accessible in code behind

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
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…

832 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