我正在开发一个网站,我希望访问该网站的人添加他们的评论。
我所做的是,我保留了一个添加按钮,当用户单击该按钮时,将弹出一个用于添加评论的弹出窗口。现在用户不应该将该字段留空。因此,我在后面的代码中进行了所需的验证,现在我想在用户尝试添加评论而不输入其中一个字段时显示模式弹出错误消息。如何显示错误消息,然后返回到评论模式弹出..
我想出的代码如下...
<asp:Button ID="addComment" runat="server" Text="Add Your Comment" OnClick="addComment_Click" style="margin-top:10px;" Height="30px" ToolTip="Add Your comment about us" Font-Bold="True" />
<asp:scriptmanager id="ScriptManager1" runat="server"></asp:scriptmanager>
<ajaxtoolkit:modalpopupextender id="ModalPopupExtender1" runat="server" cancelcontrolid="btnCancel" targetcontrolid="addComment" popupcontrolid="Panel1" popupdraghandlecontrolid="PopupHeader" drag="false" backgroundcssclass="ModalPopupBG"></ajaxtoolkit:modalpopupextender>
<asp:panel id="Panel1" style="display: none" runat="server">
<div class="HellowWorldPopup">
<div class="PopupHeader" id="PopupHeader">
<h3 style="color:white; font-family:'Palatino Linotype'">Add Your Comment</h3>
</div>
<div class="PopupBody">
<p style="font-family:'Palatino Linotype'; margin-left:10px;">Your Name :</p>
<p>
<asp:TextBox ID="txtName" Text="" runat="server" Width="300px" style="margin-left:10px; font-family:'Palatino Linotype'; font-size:medium; font-style:italic"></asp:TextBox>
</p>
<p style="font-family:'Palatino Linotype'; margin-left:10px;">Your Comment:</p>
<p>
<asp:TextBox ID="txtComment" Text="" runat="server" Width="400px" style="margin-left:10px;font-family:'Palatino Linotype'; max-height:100px; font-size:medium; resize:none; font-style:italic" TextMode="MultiLine"></asp:TextBox>
</p>
</div>
<asp:Button runat="server" id="btnOkay" Text="Done" OnClick="btnOkay_Click" style="font-family:'Palatino Linotype'; margin-bottom:10px; margin-left:10px; width:100px; height:30px; font-size:small;font-weight:700" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" style="font-family:'Palatino Linotype';width:100px; height:30px; margin-left:10px; font-size:small;font-weight:700" OnClick="btnCancel_Click" />
</div>
</asp:panel>
请帮我..
提前致谢