必填字段验证器在首次单击文本框设置为多行时不起作用

时间:2011-04-13 16:20:58

标签: asp.net textbox multiline requiredfieldvalidator

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

<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> 

1 个答案:

答案 0 :(得分:0)

将此添加到提交按钮:

OnClientClick="tinyMCE.triggerSave(false,true);"