Skip to content
This repository
Browse code

Add basic VB.NET Create view T4 template for ASP.NET MVC.

  • Loading branch information...
commit 998742e961c82dbf48860f290493e7e7fdc10d53 1 parent 8da9260
Matt Ward mrward authored
3  src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj
@@ -215,6 +215,9 @@
215 215 <None Include="ItemTemplates\VisualBasic\CodeTemplates\AddController\Controller.tt">
216 216 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
217 217 </None>
  218 + <None Include="ItemTemplates\VisualBasic\CodeTemplates\AddView\AspxVisualBasic\Create.tt">
  219 + <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  220 + </None>
218 221 <None Include="ItemTemplates\VisualBasic\CodeTemplates\AddView\AspxVisualBasic\Empty.tt">
219 222 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
220 223 </None>
72 ...endBindings/AspNet.Mvc/Project/ItemTemplates/VisualBasic/CodeTemplates/AddView/AspxVisualBasic/Create.tt
... ... @@ -0,0 +1,72 @@
  1 +<#@ template language="VB" HostSpecific="true" #>
  2 +<#@ import namespace="ICSharpCode.AspNet.Mvc" #>
  3 +<#@ import namespace="Microsoft.VisualBasic.Constants" #>
  4 +<# If MvcHost.IsPartialView Then #>
  5 +<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl<#= GetViewPageType() #>" %>
  6 +
  7 +<# ElseIf MvcHost.IsContentPage Then #>
  8 +<%@ Page Language="VB" MasterPageFile="<#= MvcHost.MasterPageFile #>" Inherits="System.Web.Mvc.ViewPage<#= GetViewPageType() #>" %>
  9 +
  10 +<asp:Content ID="Content1" ContentPlaceHolderID="Title" runat="server">
  11 +<#= MvcHost.ViewName #>
  12 +</asp:Content>
  13 +
  14 +<asp:Content ID="Content2" ContentPlaceHolderID="<#= MvcHost.PrimaryContentPlaceHolderID #>" runat="server">
  15 +<#
  16 + PushIndent(vbTab)
  17 + Else
  18 +#>
  19 +<%@ Page Language="VB" Inherits="System.Web.Mvc.ViewPage<#= GetViewPageType() #>" %>
  20 +
  21 +<!DOCTYPE html>
  22 +<html>
  23 + <head runat="server">
  24 + <title><#= MvcHost.ViewName #></title>
  25 + </head>
  26 + <body>
  27 +<#
  28 + PushIndent(vbTab & vbTab)
  29 + End If
  30 +#>
  31 +<% Using Html.BeginForm() %>
  32 + <%: Html.ValidationSummary(True) %>
  33 + <fieldset>
  34 + <legend><#= MvcHost.ViewDataType.Name #></legend>
  35 +
  36 + <p>
  37 + <input type="submit" value="Create"/>
  38 + </p>
  39 + </fieldset>
  40 +<% End Using %>
  41 +<div>
  42 + <%: Html.ActionLink("Back", "Index") %>
  43 +</div>
  44 +<#
  45 + If MvcHost.IsPartialView Then
  46 + ' Do nothing.
  47 + ElseIf MvcHost.IsContentPage Then
  48 + PopIndent()
  49 +#>
  50 +</asp:Content>
  51 +<#
  52 + Else
  53 + PopIndent()
  54 +#>
  55 + </body>
  56 +</html>
  57 +<# End If #>
  58 +<#+
  59 + ReadOnly Property MvcHost As MvcTextTemplateHost
  60 + Get
  61 + Return DirectCast(Host, MvcTextTemplateHost)
  62 + End Get
  63 + End Property
  64 +
  65 + Public Function GetViewPageType() As String
  66 + Dim viewDataTypeName As String = MvcHost.ViewDataTypeName
  67 + If Not String.IsNullOrEmpty(viewDataTypeName) Then
  68 + Return String.Format("(Of {0})", viewDataTypeName)
  69 + End If
  70 + Return String.Empty
  71 + End Function
  72 +#>

0 comments on commit 998742e

Please sign in to comment.
Something went wrong with that request. Please try again.