<p>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.</p>

[{'answer_id': 46949, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 0, 'selected': False, 'text': '<p>One way to do it, is to create a new empty masterpage/aspx-file and then copy-paste the code you allready have into that page. That will take care of all the wire-up and creating of code-files.</p>\n'}, {'answer_id': 47123, 'author': 'Andrei Rînea', 'author_id': 1796, 'author_profile': 'https://Stackoverflow.com/users/1796', 'pm_score': 0, 'selected': False, 'text': "<p>Or you can adapt the Page or Master directive while creating an appropiate code behind file (.master.cs or .aspx.cs or for VB.NET .master.vb or .aspx.vb).</p>\n\n<p>I don't know of a simple click way to achieve this.</p>\n"}, {'answer_id': 47124, 'author': 'FlySwat', 'author_id': 1965, 'author_profile': 'https://Stackoverflow.com/users/1965', 'pm_score': 3, 'selected': True, 'text': '<p>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.</p>\n\n<p>Then rightclick on your project and click "Convert to Web Application" and Visual Studio will create the designer file.</p>\n'}]
['https://Stackoverflow.com/questions/46938', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1463/']