1

我使用必填字段验证器来验证一个简单的文本框和一个文本模式设置为多行的文本框。验证器适用于简单文本框,单击提交按钮时显示错误,但不显示多行文本框的错误消息。当我第二次单击提交按钮时,它会验证两个文本框。我只是不知道它有什么问题。下面是代码:

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">

<script type="text/javascript" src="../Scripts/tiny_mce/tiny_mce.js"></script> 
<script type="text/javascript"> 
tinyMCE.init({ 
// General options 
 mode: "textareas", 
theme: "simple",
 encoding: "xml"

 } 
 ); 

 <script type="text/C#">
 public string BodyHtml
 {
  get { return HttpUtility.HtmlDecode(txtDescription.Value); }
  set { txtDescription.Value = value; }
 }

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:Label ID="lblTitle" runat="server" Text="Title (required)"></asp:Label>
 <br /> <asp:TextBox ID="txtTitle" runat="server" Width="557px"></asp:TextBox>
<%--<asp:RequiredFieldValidator ID="reqTitle" runat="server" ErrorMessage="*"ControlToValidate="txtTitle"></asp:RequiredFieldValidator>--%>
<asp:Label ID="lblDescription" Text="Description (required)" runat="server"></asp:Label>


<%--<asp:RequiredFieldValidator ID="reqDescription" runat="server" ErrorMessage="*" ControlToValidate="txtDescription" ></asp:RequiredFieldValidator>--%>



<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Save" 
    onclick="btnSubmit_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label> 

4

1 回答 1

0

将此添加到提交按钮:

OnClientClick="tinyMCE.triggerSave(false,true);"
于 2017-06-13T12:42:25.757 回答