I have a Button which is having modalpopupextender which is working absolutely fine no problem at all, but before the modalpopup appears i want to validated text box control if it is not valid then modalpopup should not appear other wise it should work as usual.. does anybody having idea.
我有一个有modalpopupextender的按钮,它完全没问题,但是在modalpopup出现之前,我想要验证文本框控件,如果它不有效,那么modalpopup就不会出现了。有人有想法。
2 个解决方案
#1
3
We use following function. On the button click you can call this function. This will validate validation group that is passed to this function and it is work will pop the modal popup otherwise validation error will appear.
我们使用以下函数。在按钮上,你可以调用这个函数。这将验证传递给此函数的验证组,它将弹出模式弹出,否则验证错误将出现。
function ClientSideValidate(modalId,group)
{
var modal = $find(modalId);
Page_ClientValidate(group);
if(!Page_IsValid)
{
modal.show();
}
}
#2
0
Something I've done in the past is manually show/hide the modal popup. I realize the ModalPopupExtender control requires a target, so you'll need a dummy target which will remain inactive:
我过去做的一些事情是手动显示/隐藏模式弹出。我意识到ModalPopupExtender控制需要一个目标,所以你需要一个假目标,它将保持不活动:
<asp:LinkButton id="btnDummyTarget" runat="server" />
<asp:Button
id="btnActualButtonTiedToValidation"
ValidationGroup="SomeValidationGroup"
OnClick="MyButton_Click"
runat="server" />
<ajaxToolkit:ModalPopupExtender
id="mpeMyPopup"
PopupControlID="pnlSomePanelToShow"
TargetControlID="btnDummyTarget"
runat="server" />
Then, in your codebehind you can do the following:
然后,在你的代码后面你可以做以下事情:
protected void MyButton_Click(object sender, EventArgs e)
{
if(Page.IsValid)
mpeMyPopupExtender.Show();
}
This is also handy for delete confirmation dialogs.
这对于删除确认对话框也很方便。
#1
3
We use following function. On the button click you can call this function. This will validate validation group that is passed to this function and it is work will pop the modal popup otherwise validation error will appear.
我们使用以下函数。在按钮上,你可以调用这个函数。这将验证传递给此函数的验证组,它将弹出模式弹出,否则验证错误将出现。
function ClientSideValidate(modalId,group)
{
var modal = $find(modalId);
Page_ClientValidate(group);
if(!Page_IsValid)
{
modal.show();
}
}
#2
0
Something I've done in the past is manually show/hide the modal popup. I realize the ModalPopupExtender control requires a target, so you'll need a dummy target which will remain inactive:
我过去做的一些事情是手动显示/隐藏模式弹出。我意识到ModalPopupExtender控制需要一个目标,所以你需要一个假目标,它将保持不活动:
<asp:LinkButton id="btnDummyTarget" runat="server" />
<asp:Button
id="btnActualButtonTiedToValidation"
ValidationGroup="SomeValidationGroup"
OnClick="MyButton_Click"
runat="server" />
<ajaxToolkit:ModalPopupExtender
id="mpeMyPopup"
PopupControlID="pnlSomePanelToShow"
TargetControlID="btnDummyTarget"
runat="server" />
Then, in your codebehind you can do the following:
然后,在你的代码后面你可以做以下事情:
protected void MyButton_Click(object sender, EventArgs e)
{
if(Page.IsValid)
mpeMyPopupExtender.Show();
}
This is also handy for delete confirmation dialogs.
这对于删除确认对话框也很方便。