Solved

New ASP control not accessible in code behind

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Initial get page response times and IIS8 15 55
Reading the Web.Config using IIS 7.5? 4 49
tutorial for ebay api 3 55
asp enable view state 1 28
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 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