显示在控制的模式弹出扩展消息框 [英] showing message box on control's modal popup extender
本文介绍了显示在控制的模式弹出扩展消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网页,有以下模式弹出扩展的内部控制:
I have a control inside a page that has the following modal popup extender:
<asp:Panel ID="pnl_Completed" runat="server">
<asp:Image ID="exit_Completed" runat="server" ImageUrl="" />
<h3 style="text-align:center;">Completed</h3>
<asp:Panel ID="pnl_inner" runat="server">
<table style="width:100%;height:100%" cellpadding="5px">
<tr style="height:40px;">
<td valign="top">Comment: </td>
<td>
<telerik:RadTextBox ID="txt_CompletedComment" runat="server" TextMode="MultiLine" Rows="6" Width="400" Height="100"></telerik:RadTextBox>
</td>
</tr>
<tr style="height:40px;">
<td colspan="2" align="center"><asp:Button id="btn_SaveCompleted" runat="server" Text="Complete" OnClick="btn_SaveCompleted_Click" /></td>
</tr>
</table>
</asp:Panel>
</asp:Panel>
<cc1:ModalPopupExtender ID="ModalPopupExtender_Completed" runat="server" PopupControlID="pnl_Completed" CancelControlID="exit_Completed" TargetControlID="dummy_btn_Completed" >
</cc1:ModalPopupExtender>
<asp:Button id="dummy_btn_Completed" runat="server" CssClass="display_none" />
我要显示在btn_SaveCompleted_Click事件一个消息时,文本框为空,我已经试过这样:
I want to show a messagebox on btn_SaveCompleted_Click event when the textbox is empty I have tried this:
If txt_CompletedComment.Text.Trim().Length = 0 Then
ScriptManager.RegisterStartupScript(Me, Me.GetType, "key", "alert('Please enter a comment.');", True)
End If
但是这并不工作,它只是隐藏模式弹出扩展,没有任何错误。我是不是做错了?是否有任何其他方式来显示呢?
but this doesnt work it just hides the modal popup extender, with no errors. Am I doing it wrong? Is there any other way to show it?
推荐答案
只需使用的JavaScript
,还有一堆的方式来做到这一点这里是一个例子:
Just use JavaScript
, there a bunch of ways to do it here is one example:
<asp:Button id="btn_SaveCompleted" runat="server" Text="Complete"
OnClientClick="return ValidateTheTextbox();"OnClick="btn_SaveCompleted_Click" />
<script>
function ValidateTheTextbox()
{
var txtbox = document.getElementById('<%= txt_CompletedComment.ClientID %>');
if(txtbox.value=="")
{
alert('Please enter a comment.');
return false; //suppress the submit button
}
return true; //let the form submit
}
</script>
这篇关于显示在控制的模式弹出扩展消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文