在控件的模态弹出扩展器上显示消息框 [英] 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屋!
查看全文