0

I want to associate some code behind with my master page by using the html/master conversion.

I added something like this just after LocalBinding in my html file:

<!--SPM:<%@ Master language="C#" Inherits=" [...] " %>-->

But the conversion process add this line in the master file:

<%@Master language="C#"%>

Is there a way to do this without adding programmatically the correct line to the master page?

Thanks.

1

I'm not 100% sure if this is possible when working with html design files that get converted to a master page. A code behind is custom code that needs to be deployed to the server. The Design Manager will not package this code when creating a Design Package. Design Packages are Sandbox solutions and Sandbox solutions do not support code behind (anymore).

What can you do? Download the master page that you already have. (master page, not the html file). Create a Visual Studio farm solution. Add the master page to this solution together with your code-behind. Deploy this package to the server.

Depending on what your requirement are, you can also create a user-control in Visual Studio. Add your code to the suer-control. Deploy this user-control to the server as a farm solution and simply reference this (custom) user-control in your html master page. This way you can continue to work with the html page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.