Reputation: 65
I am currently using Visual Studio 2012 to design aspx pages and have a page which uses a MasterPage which I will call it "a.aspx" for simplicity's sake, and unlike my other pages, "a.aspx" does not have a .cs file attached to it which I assume is because it had a Master Page. Whenever I drag items like buttons into the contentholder of "a.aspx", the code behind page brings me to the aspx page and not the cs page. And I can't import assembly references which I need to because I require some SQL connection in "a.aspx"
So how can I create a webform with a master page while being able to have the contents within my contenthandler to be mqanipulated through a .cs file or can I perform functions in the aspx page too?
Upvotes: 0
Views: 679
Reputation: 5636
This place code in separate file
option depends on the type of project you are building:
1) If you are building a Web Application then (File | New > Project, doesn't have an /App_Code folder, compiles all .cs/.vb files into one .dll in the /bin folder)
then you don't have the option to not create a separate code file, and when you add a new item it's either a Web Form
or a Web Form using Master Page
.
2) If you are building a Web Site (File | New > Web Site, contains an /App_Code folder, the code is not compiled into a .dll in the /bin folder)
then you will have the option (ticked by default in VS2008/2010/2012) to Place code in separate file
, and also Select master page
.
Upvotes: 0
Reputation: 1700
You can have all your functions in same aspx file, or you can divide it into two files: aspx and cs. Just enable "place code in separate file" checkbox in "add new item" dialog.
Upvotes: 1