Guide to importing .aspx with .aspx.cs files in Umbraco 7
Hi All,
I'm new to Umbraco and although there are some slightly similar posts regarding this, they are a few years old or do not answer everything.
1. Starting with the aspx.cs file. I've read that this needs to become a master.cs file so in the backend under the 'Masterpages' folder, I have created a MasterPage.master.cs file and copied everything from aspx.cs into it.
Please can you confirm whether this is still the correct method?
1.1. If so, what does my namespace name change to? In visual studio it was the name of the project however in Umbraco, what do I use? default.Master? Change the class name to Root and System.Web.UI.Page to System.Web.UI.MasterPage? There's not error at the moment but I've kept the namespace as it is and will let you know if there is a problem.
2. The aspx file. I have created a template which references the masterpage.master.cs file I created. It seems to be picking it up fine, however I had an asp form in my aspx file which the template is not picking up on and it is not shown in the content of the file. E.g.:
Please can you confirm point 1 and support me on point 2? It would be much appreciated as there is not really any official documentation or user guides.
Guide to importing .aspx with .aspx.cs files in Umbraco 7
Hi All,
I'm new to Umbraco and although there are some slightly similar posts regarding this, they are a few years old or do not answer everything.
1. Starting with the aspx.cs file. I've read that this needs to become a master.cs file so in the backend under the 'Masterpages' folder, I have created a MasterPage.master.cs file and copied everything from aspx.cs into it.
Please can you confirm whether this is still the correct method?
1.1. If so, what does my namespace name change to? In visual studio it was the name of the project however in Umbraco, what do I use? default.Master? Change the class name to Root and System.Web.UI.Page to System.Web.UI.MasterPage? There's not error at the moment but I've kept the namespace as it is and will let you know if there is a problem.
2. The aspx file. I have created a template which references the masterpage.master.cs file I created. It seems to be picking it up fine, however I had an asp form in my aspx file which the template is not picking up on and it is not shown in the content of the file. E.g.:
[code]
<%@ Master Language="C#" MasterPageFile="~/Masterpages/MasterPage.master.cs" AutoEventWireup="true" %>
<form runat="server" id= "form" >
<asp:TextBox ID="txtUsername" runat="server" />
<asp:Button Text="Submit" runat="server" OnClick="btnSubmit" />
</form>
[/code]
Please can you confirm point 1 and support me on point 2? It would be much appreciated as there is not really any official documentation or user guides.
Kind regards,
Steph
No problem guys, I have now solved this after spending a little time on it today.
Anyone else which is looking to solve this, please see below:
In the aspx.cs file, all I did was remove the namespace and keep it saved as a master.cs file within the Masterpages folder.
In the aspx file, I copied it into a template with the below:
[code] <%@ Master Language="C#" CodeFile="~/Masterpages/MasterPage.master.cs" Inherits="test" %> [/code]
The inherits 'test' matched up tothe class name:
[code] public partial class test : System.Web.UI.MasterPage {[/code]
Now I am going to try and link it to the main master page so it can pick up on the main CSS. If there is anyone out there, please feel free to advise.
is working on a reply...