views:

93

answers:

1

Using Visual Studio 2008, I need to create a custom web form that when picked acts like the web content form, by providing a dialog that lets you pick a master page. I have looked through the webform.zip template and thought I had a clue, but trying different combinations has baffled me as it either doesn't appear or doesn't work.

Also when you set the project type to Web and sub project type to CSharp it doesn't appear, so I don't know if this part of the cause, because I would of hoped that the SupportsMasterPage element would of caused this dialog to appear, if it is a web item, but no luck. Frown

Any ideas?

p.s. I have used my googling resources to the maximum so unsure what to do.

+2  A: 

If you're using a website, then a web form template with the key: SupportsMasterPage is what you're looking for:

<VSTemplate Version="3.5.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2008" Type="Item">
  <TemplateData>
    <DefaultName>myfilename.aspx</DefaultName>
    <Name>myPageName</Name>
    <Description>My description</Description>
    <ProjectType>Web</ProjectType>
    <ProjectSubType>VisualBasic</ProjectSubType>
    <SortOrder>10</SortOrder>
    <Icon>__TemplateIcon.ico</Icon>
        <SupportsCodeSeparation>true</SupportsCodeSeparation>
        <SupportsMasterPage>true</SupportsMasterPage>
  </TemplateData>
</VSTemplate>

If you have a web appliction project, you'll need the to use a template for the Web Content Form. I don't have a code sample for that exact template, but it should not be much different if at all.

Also, to get your template to appear they have to be zipped and loaded into the templates directory on your system:

%myDocuments%\Visual Studio 2008\Templates\ItemTemplates\

And they need to be loaded into the appropriate language/sub folder.

Joel Etherton
Hi Joel, my code matches that 100%, except CSharp instead of VisualBasic. It will not show up on the template selection screen under user templates. If I change the project type to CSharp, therefore removing the Web part, it shows up, but alas, no dialog :/ I'm creating a web application. Do you mean I need to edit the WebContentForm template? I have tried making a copy, editing and installing at that location this but it does again not appear as a seperate entity.
Pete
@Pete: Yah, with a web application it needs to be a WebContentForm template. In applications, WebForms have no master page assignment natively.
Joel Etherton
Cheers Joel, that clears that up (how rubbish)!!
Pete