C# ajax命令忽略指定的按钮

C# ajax命令忽略指定的按钮,c#,jquery,html,ajax,C#,Jquery,Html,Ajax,有没有办法让AjaxBeginForms忽略某些指定的按钮 例如,我的代码是: @using (Ajax.BeginForm("CreatePost", "Accounts", new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", LoadingElementId = "loading", OnBegin = "TransferContentEditableToHidde

有没有办法让AjaxBeginForms忽略某些指定的按钮

例如,我的代码是:

@using (Ajax.BeginForm("CreatePost", "Accounts", new AjaxOptions
{
   InsertionMode = InsertionMode.Replace,
   HttpMethod = "POST",
   LoadingElementId = "loading",
   OnBegin = "TransferContentEditableToHiddenTextArea()",
   OnSuccess = "$('#CreateMessage').css('display','block');",
   UpdateTargetId = "CreateMessage"
}))
{
   @Html.AntiForgeryToken()
   @Html.Label("Post Title", new { @style = "padding-right:3px;" })
   @Html.TextBoxFor(model => model.BlogTitle, new { @required = "require", @style = "width:100%;", @class = "form-control" })

   @Html.Label("Post Blog", new { @style = "padding-right:3px;" })
   <ul id="postModifierButtonsGroup">
      <li><span class="btn btn-primary btn-xs" ><i class="fa fa-bold"></i></span></li>
      <li><span class="btn btn-primary btn-xs" ><i class="fa fa-italic"></i></span></li>
      <li><span class="btn btn-primary btn-xs" ><i class="fa fa-underline"></i></span></li>
   </ul>
   <p class="form-control" id="contentEditableTextBox" contenteditable="true"></p>
   @Html.TextAreaFor(model => model.BlogPost, new { id = "hiddenTextbox", @required = "require", @style = "display:none;resize: none; width:100%; height: 130px; font: 16px tahoma;", @class = "form-control" })

<input type="submit" class="btn btn-success" value="Submit"/>
}
@使用(Ajax.BeginForm(“CreatePost”、“Accounts”、新的AjaxOptions
{
InsertionMode=InsertionMode.Replace,
HttpMethod=“POST”,
LoadingElementId=“正在加载”,
OnBegin=“TransferContentEditableToHiddenTextArea()”,
OnSuccess=“$('#CreateMessage').css('display','block');”,
UpdateTargetId=“CreateMessage”
}))
{
@Html.AntiForgeryToken()
@Label(“Post Title”,新的{@style=“padding right:3px;”})
@TextBoxFor(model=>model.blogtTitle,新的{@required=“require”,@style=“width:100%;”,@class=“form control”})
@Label(“Post Blog”,new{@style=“padding right:3px;”})

@Html.TextAreaFor(model=>model.BlogPost,新{id=“hiddenTextbox”、@required=“require”、@style=“display:none;resize:none;width:100%;height:130px;font:16px tahoma;”,@class=“form control”}) }
因此,我有两个字段,一个是post,一个是title,这两个字段将进入到带有c#backend的ajax调用中。问题是我刚刚添加了粗体、斜体和下划线按钮,它们与ajax表单冲突。如果我想向我添加粗体文本,表单将尝试提交。
有没有办法在按钮上指定它不属于我的ajax调用的一部分?

如果不希望按钮提交表单,可以添加以下属性:

type="button"
如果表单中的任何按钮标记为type=“submit”,则它将提交该表单