Convert Web Form to Web Content Form after the fact. (.net)

给你一囗甜甜゛ 提交于 2019-12-25 01:42:46

问题


I have a site a few years old that contains about 30 aspx Web Form pages with code behind. I want to add a common master page to all these with the minimum amount of work.

Essentially, I just need to add everything in the body tags to the Content Placeholder, and preserve the code behind.

Is there a fast way to do this?


回答1:


For each page do the following - Add an attribute to the <@Page > tag named MasterPageFile="Your MasterPage Path" - Add the following tag - Remove html and head tags and their contents except body tag - Remove the body tags BUT KEEP its contetnts - Remove the form tag - Done




回答2:


cut and paste works fine - cut out all the old header/footer stuff and paste in the content control tag, and add the masterpage name and you're done




回答3:


One thing to keep in mind is when you add a master page you are adding a naming container so all of your client id's will change. If you have any static javascript which is tied to your controls be sure to update the id's.



来源:https://stackoverflow.com/questions/270385/convert-web-form-to-web-content-form-after-the-fact-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!