如何将 aspx 或母版页文件转换为页面和代码隐藏? [英] How do you convert an aspx or master page file to page and code behind?

查看:32
本文介绍了如何将 aspx 或母版页文件转换为页面和代码隐藏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,其中创建了一个 .master 页面而没有代码隐藏页面.现在我想为这个 .master 页面添加一个代码隐藏页面,并将页面内"代码移动到代码隐藏文件中.执行此操作的最佳/最简单方法是什么?我使用的是 Visual Studio 2008.

I have a project where a .master page was created without a code behind page. Now I want to add a code behind page for this .master page and move the "in page" code to the code behind file. What is the best/easiest way to go about doing this? I'm using Visual Studio 2008.

推荐答案

创建新的类文件,将其命名为 yourmaster.master.cs(Visual Studio 会自动将其与 .master 分组)并将代码移动到它,引用它在您的主页中.

Create new class file, name it yourmaster.master.cs (Visual Studio will automaticly group it with the .master) and move the code to it, reference it in your masterpage.

然后右键单击您的项目并单击转换为 Web 应用程序",Visual Studio 将创建设计器文件.

Then rightclick on your project and click "Convert to Web Application" and Visual Studio will create the designer file.

这篇关于如何将 aspx 或母版页文件转换为页面和代码隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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