创建隐藏文件code ASPX被创建之后 [英] Create code behind file after aspx has been created

查看:121
本文介绍了创建隐藏文件code ASPX被创建之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚继承,是由设计师创建了一个网站。该网站最初是用所有的* .html文件创建。设计师改名为所有* .html文件为* .aspx文件。因此,有没有创建aspx.cs文件。我把网站变成一个新的VS2012的解决方案。我的问题是,有没有在VS 2010中的方式来自动创建一个现有的独立aspx文件?

I just inherited a web site that was created by a designer. The site was originally created with all *.html files. The designer renamed all the *.html files to *.aspx files. Hence there are no aspx.cs files created. I pulled the site into a new VS2012 solution. My question is, is there a way in VS 2010 to automatically create the code behind files for a an existing stand alone aspx file?

推荐答案

我不知道的一个自动化的方式来做到这一点,但如果没有服务器端code在现有的* .aspx文件,然后它应该只是添加的.cs codebehind文件,然后将它们连接起来的情况下的<%@页标签,像这样:

I don't know of an automated way to do this, but if there is no server side code in the existing *.aspx files then it should just be a case of adding the .cs codebehind files and then wiring them up in the <%@ Page tag like so:

<%@ Page Title="YourPageTitle" Language="C#" AutoEventWireup="true" CodeBehind="YourPage.aspx.cs" Inherits="YourNamespace.YourPage" %>

请注意:这不会创建 YourPage.aspx.designer.cs 文件。 (我通常因为它们会导致合并问题,删除这些无论如何 - 我觉得它更容易添加我需要引用我的code-隐藏文件手动控制)

Note: This will not create the YourPage.aspx.designer.cs file. (I usually delete these anyway as they cause merge issues - i find it easier to add the controls i need to reference to my code-behind file manually.)

另一种方法是只创建一个新的Web窗体,了解正确的名称每一页,然后复制现有的标记贴到他们。如果你有在现有的* .aspx文件服务器code,那么你将需要手动将其复制到code-落后。

The other alternative is to just create a new "Web Form" for each page with the correct names and then copy and paste the existing markup into them. If you do have server code in the existing *.aspx files then you will need to manually copy it to the code-behind.

这篇关于创建隐藏文件code ASPX被创建之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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