开发者

ASP.NET Controls are not coming in Code-behind IntelliSense

I am having an aspx page where I have added one asp.net text box control with ID and RUNAT attribute. But in Code-behind I am not seeing this control's name in the inte开发者_如何学运维llisense.

My page directive in aspx is as follows

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyProject_UI._Default" %>

I am using VS 2008. Any idea how to get rid of this?


Try using CodeFile instead of CodeBehind. The latter is a hold-over from .NET 1.1.

Also, make sure the namespaces match up between the markup and the code. Do a test compile to be sure.


I have seen this on occasion when I edit a page. When it happens to me, I close the files and open them again and it seems to fix itself.


This will happen if you are trying to include your control in LayoutTemplate. For example if you are using an asp label in a login control you have converted to a LayoutTemplate.

<asp:Login ID="userLogin" runat="server">
   <LayoutTemplate>
     <!--Username and password controls-->
     <asp:Button ID="btnLogin" CommandName="Login" runat="server" Text="Login" />
     <asp:Label ID="lblAlert" runat="server"></asp:Label>
   </LayoutTemplate>

So your lblAlert will not show up on the code behind take it out of the layouttemplate or use a loop to find the control within the layout object.

var mylabel = (Label)userLogin.FindControl("lblAlert");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜