Sunday, August 26, 2007

Need a custom ASPX in Sharepoint and not use a Master Page etc?

It's simpler than you may think. The proper way to put the file in the 12-hive would be to use a solution to deploy it (I deployed it as a feature). I'm not going into detail on how to do that part. This how to do it manually.

OK, so create your page as you normally create one. If you want code behind, you'll have to compile the DLL and place it in the Bin/GAC, then you'll need to add a reference to it in the web.config of the application as a safe control. That will cause your web application to load the DLL so you can use it.

After you get it looking how you want, simply copy the aspx page to a location in the 12-hive. Most say use \layouts\Custom\yourpage.aspx. No problems with putting it there.

In your browser the address will look something like this: http://yoursite/_layouts/Custom/yourpage.aspx

Here is an example of one (I don't know how to insert code blocks yet, if you can help, send me an email so I can make the code look better.):

ASPX Page:

<%@ Assembly Name="your.assembly.name (this is the dll for your code behind), version, etc" %>
<%@ Page language="C#" Inherits="your.assembly.name.CLASSNAME(Code Behind)" %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<form>
Hi
</form>
</BODY>
</HTML>

If you don't use a code behind, remove the assembly reference and the "Inherits" property.

If you need more details, let me know.

No comments: