aspx.designer.cs它是如何工作的? [英] aspx.designer.cs how does it work?

查看:95
本文介绍了aspx.designer.cs它是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的是一个初学者,所以我的问题可能看起来很荒谬..但是,我想知道文件 .aspx.designer.cs 是如何工作的. 这是我第一次使用包含每个页面文件 .aspx.designer.cs 的解决方案.因此,我知道它是.aspx中用于代码隐藏的控件的声明.

I'm a really beginner so my question may be appear ridiculous.. But, i wonder how the files .aspx.designer.cs works.. It's the first time i work with a solution containing files .aspx.designer.cs for each pages. So i understand it's declaration of controls used in the .aspx for code-behind..

这是我的问题:

为什么有时解决方案没有.aspx.designer.cs文件? (文件是隐藏的还是不存在?)

Why sometimes solutions doen't have .aspx.designer.cs files? (is the files hidden or doesn't exists?)

我经常对此文件有问题,当我在.aspx代码中添加一些控件时,它们不会自动重新创建控件的声明,我在做什么错了?

I often have problems with this files, they don't Automatically recreate declarations of controls when i add some in the .aspx code, what am i doing wrong?

推荐答案

.aspx.designer.xx文件是ASP.NET Webforms代码隐藏文件和.aspx标记文件的桥梁. .aspx标记页上存在的任何服务器控件均在此处表示.最重要的是服务器控件的名称和类型.

The .aspx.designer.xx files are the bridge for the ASP.NET webforms code-behind files and the .aspx markup files. Any server control existing on the ,aspx markup page is represented here. Most important are the name and type of the server control.

在某种程度上,这允许Visual Studio在代码隐藏页面中为用户提供IntelliSense,以用于在设计时创建的服务器控件.

This, in part, allows Visual Studio to give the user IntelliSense in the code-behind page for server controls created at design-time.

它们的工作方式:当您从设计器添加/删除服务器控件时,Visual Studio将在.designer文件中生成或同步一个protected成员.

How they work: Visual Studio will generate, or keep in sync, a protected member in the .designer file when you add/remove a server control from the designer.

  protected global::System.Web.UI.WebControls.DropDownList DropDownList1;

请注意,.designer文件将创建一个partial class.这提供了到代码隐藏文件的链接.这就是Intellisense如何在.aspx和后台代码之间建立联系的方式.

Notice that .designer files create a partial class. This provides the linkage to the code-behind file. That's how Intellisense gets the hook between the .aspx and the code-behind.

您可以重新生成设计器文件: http://www.undermyhat.org/blog/2009/07/tip-regenerate-aspx-designer-cs-files-when-corrupted/

You can regenerate your designer file: http://www.undermyhat.org/blog/2009/07/tip-regenerate-aspx-designer-cs-files-when-corrupted/

这篇关于aspx.designer.cs它是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆