gpt4 book ai didi

c# - 在@using 语句中使用三元

转载 作者:太空宇宙 更新时间:2023-11-03 23:41:13 26 4
gpt4 key购买 nike

全部,

我正在尝试使用@using 语句实现一个三元组,以便在我的三元组中定义的某些情况下切换出@enctype。我收到 Razor 解析错误,指出我在 @using 语句中缺少结束符“}”。这个错误具有误导性,因为我所有的花括号都匹配得很好。我包含了整个表格,因为我看不到三元部分的语法有任何明显的问题。

看起来问题是 if/else block ,但不确定为什么......

知道为什么这是有问题的吗?有更好的方法吗?

@using(Ajax.BeginForm("ProcessCompose", 
"ClubOpeningTool",
FormMethod.Post,
new AjaxOptions { UpdateTargetId = "update_panel" },
new { enctype = (fileAttachmentUnsupported ? "application/x-www-form-urlencoded" : "multipart/form-data"),
id = "ComposeForm" }))
{

@Html.ValidationSummary(true)
<fieldset style="width:90%">
<p class="required"><strong>* Required</strong></p>
<div id="update_panel"></div>
<div>
<span style="font-weight:bold; font-size:14px; color:#000000;">To:</span>
</div>
<div>
<table id="compose" class="table-grid">
<tr>
<td><strong>Available @(isTeam? "Team Mambers": Model.Mode)</strong> <br />
@Html.ListBox("AvaliableRecipients", Model.AvailabeRecipients, new{@class="ncb-listbox"})
</td>
<td><button id="addAllRecipient" type="button">>></button><br /><button id="addRecipient" type="button">> </button><br /><button id="removeRecipient" type="button">< </button><br /><button id="removeAllRecipient" type="button"><<</button>
<script type="text/javascript">
$(function () {
$('#addRecipient').click(function () {
$('#AvaliableRecipients option:selected').appendTo('#Recipients');

});
$('#addAllRecipient').click(function () {
$('#AvaliableRecipients option').appendTo('#Recipients');
$("#Recipients option").attr("selected", "selected");

});

$('#removeRecipient').click(function () {
$('#Recipients option:selected').appendTo('#AvaliableRecipients');
});

$('#removeAllRecipient').click(function () {
$('#Recipients option').appendTo('#AvaliableRecipients');
});

});

$("form").submit(function () {
$('#Recipients').find("option").attr('selected', 'true');
});
</script>
</td>
<td><strong>Current Recipients</strong>&nbsp;<span class="required">*</span><br />
@Html.ListBox("Recipients", Model.Recipients,new{@class="ncb-listbox"})<br /><span class="messageBottom">@Html.ValidationMessageFor(model => model.Recipients)</span>
</td>
</tr>

</table>

</div>

<div>
@Html.LabelFor(model => model.Subject) &nbsp;<span class="required">*</span>
</div>
<div>
@Html.EditorFor(model => model.Subject)<br />
<span class="messageBottom">@Html.ValidationMessageFor(model => model.Subject)</span>
</div>
@if (!fileAttachmentUnsupported)
{
<div>
<label>
File Attachment @Html.DisplayFor(model => model.FileName)
</label> <i>(9MB file size limit)</i>

</div>

<input class="js-file-text" type="text" id="fileUploadFileName" name="fileUploadFileName">

@Html.TextBoxFor(model => model.FileAttachment, new {type = "file", @class = "js-file-field"})
<a class="btn blue js-file-btn">Browse</a>
}
else
{
<div>
<label>
<b>Attachment feature not available for Internet Explorer 10 (IE10 or earlier)</b>
</label>
</div>
}


@Html.HiddenFor(model => model.EmailID)
@Html.HiddenFor(model =>model.NewClubId)
@Html.HiddenFor(model =>model.Mode)
@Html.HiddenFor(m => m.DraftOrSentViewMode)
<div>
@Html.LabelFor(model => model.Body)&nbsp;<span class="required">*</span>
</div>
<div>
@Html.TextAreaFor(model => model.Body)<br />
<span class="messageBottom">@Html.ValidationMessageFor(model => model.Body)</span>
</div>


<p>
<input type="submit" id="btnComposeSend" name="Command" value="Send" class="btn blue saveSend"/>
@if (! isTeam) {
<input id="btnComposeSave" type="submit" name="Command" value="Save" class="btn blue saveSend"/>
}
</p>
</fieldset>


}

最佳答案

不确定为什么这不起作用,也许发布整个 View ?话虽如此,如果是我,我会试试这个……

@using(Ajax.BeginForm(
"ProcessCompose",
"ClubOpeningTool",
FormMethod.Post,
new AjaxOptions { UpdateTargetId = "update_panel" },
new { @enctype = (fileAttachmentUnsupported ? "application/x-www-form-urlencoded" : "multipart/form-data"), id = "ComposeForm" }))
{ ... }

关于c# - 在@using 语句中使用三元,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28963946/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com