基本上我有一个视图,其中包含3个不同页面的模板。但是,与第一个页面相比,这些页面中的2个页面需要不同的内容。我的第一个想法是在表中有一个IF语句,它检查页面的ID是什么,因此如果结果为真,则显示表的这一部分。但是,视图没有获取页面的ID,只是总是离开表格的部分。我的第二个想法是使用Html.RenderPartial并根据ID渲染表,但这也不起作用。有没有人知道如何获取页面的ID然后使用它来创建一个if语句而不创建3个不同但几乎相同的视图?我的代码如下:
<% Using Html.BeginForm("SubmitEmailTemplate", "Maintenance", Nothing, FormMethod.Post, New With {.id = "formEditTemplate"})%>
<%: Html.Hidden("txtEmailTemplateID", Model.EmailTemplate.EmailTemplateID)%>
<%: Html.Hidden("txtEmailTemplateType", Model.EmailTemplate.EmailTemplateType)%>
<%: MasterPageHelpers.ContainerStart("wid1", "Email Templates", 16)%>
<table class="layout-standard-table" cellpadding="0" cellspacing="0">
<tr>
<td class="prompt">Subject</td>
<td class="details"><%: Html.TextBox("txtSubject", Model.EmailTemplate.Subject)%><button type="button" onclick="DialogMerge('txtSubject')" title="Insert Merge Fields"><img src="<%: Url.Content("~/content/img/icons/plus.png")%>" alt="" /> Insert Merge Fields</button></td>
</tr>
<tr>
<td class="prompt">Body</td>
<td><%: Html.TextArea("txtBodyText", Model.EmailTemplate.BodyText)%> <button type="button" onclick="DialogMerge('txtBodyText')" title="Insert Merge Fields"><img src="<%:Url.Content("~/content/img/icons/plus.png")%>" alt="" /> Insert Merge Fields</button></td>
</tr>
</table>
<br />
<div>
<button type="button" onclick="SaveTemplate()" title="OK"><img src="<%: Url.Content("~/content/img/icons/tick.png")%>" alt="" /> OK</button>
<button type="button" onclick="NavigateBack()" title="Cancel"><img src="<%: Url.Content("~/content/img/icons/cross.png")%>" alt="" /> Cancel</button>
</div>
<div id="divInsertMergeFieldSubject" style="display:none"">
<table class="layout-standard-table" cellpadding="0" cellspacing="0">
<thead>
<tr>
<td>Merge Field</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<td><a onclick='InsertMergeField("Owner")'>Owner</a></td>
<td>The Owner of the ticket</td>
</tr>
<tr>
<td><a onclick='InsertMergeField("Client")'>Client</a></td>
<td>The Client</td>
</tr>
<tr>
<td><a onclick='InsertMergeField("Description")'>Description</a></td>
<td>The Decription of the ticket</td>
</tr>
<tr>
<td><a onclick='InsertMergeField("Notes")'>Notes</a></td>
<td>The Notes</td>
</tr>
<tr>
<td><a onclick='InsertMergeField("Classification")'>Classification</a></td>
<td>The Classification of the ticket</td>
</tr>
<!-- The IF statement -->
<% If Model.EmailTemplate.EmailTemplateID = 2 Or 3 Then%>
<tr>
<td><a onclick='InsertMergeField("ResponseBy")'>Response By</a></td>
<td>The person who responded to the ticket</td>
</tr>
<% End If%>
</tbody>
</table>
</div>
答案 0 :(得分:0)
<% If Model.EmailTemplate.EmailTemplateType = 2 Or Model.EmailTemplate.EmailTemplateType = 3 Then%>
<tr>
<td><a onclick='InsertMergeField("ResponseBy")'>Response By</a></td>
<td>The person who responded to the ticket</td>
</tr>
<% End If%>