1

Probably a question with an obvious answer, but I'm lost. How do you add a custom aspx page (with code behind) to a project in visual studio 2008 for sharepoint 2007.

I've created the project using wspbuilder and have added a feature with receiver and other custom classes, but I find no way to add a custom aspx.net page.

Any help?

ps. once I've added it, what will be the url of it?

thanks

Edit: I've created the folder structure suggested, but I can't find a Web Form in the list of items I can add to that folder. I've created the project as a WSPBuilder project. How can I install my missing templates

Edit2: Ok adding a new guid to the ProjectTypeGuids in the .csproj file I was able to add an aspx page at 12/template/layouts/UFeature/test.aspx

    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Page Language="C#"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    public static string output;
    protected void Page_Load(object sender, EventArgs e)
    {
        SPUser user;
        output = "Ciao";
    }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        Prova
        <%=output%>
        </div>
        </form>
    </body>
    </html>

Now my problem is that it doesn't find SPUser even thought I've added the import of Microsoft.Sharepoint.

1 Answer 1

3

You need to create the directory structure in your solution for WSPBuilder to package & deploy it correctly.

The structure will be something like:

12\TEMPLATE\LAYOUTS\MyProjectName\

Once you've got that, you can create new ASP.NET Web Forms in that folder, and they'll be deployed with the WSP.

The URL to access them will be something like

http://myserver/sites/mywebsite/_layouts/MyProjectName/MyNewAppPage.aspx

3
  • I can't find a Web Form in the list of items I can add to that folder Commented Aug 22, 2012 at 6:58
  • @MaurizioPz Try installing the CKSDev extention for VS, then it should appear.
    – user2536
    Commented Aug 22, 2012 at 7:24
  • @Dandroid it seems to be for visual studio 2010, I'm on VS 2008 Commented Aug 22, 2012 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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