I am using a model popup extender in my page. I have created some rule. If that rule is true, then show model popup extender otherwise hide it.I am using the below code to display model popub extender.
<asp:ModalPopupExtender runat="server" ID="modelPopupExtender1" TargetControlID="Lnk_1"
PopupControlID="pan_addEdit" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
<asp:Panel ID="pan_addEdit" runat="server" CssClass="pnl">
<asp:LinkButton ID="Lnk_1" runat="server" OnClick="btn_generate_Click" Visible="true"></asp:LinkButton>
<table border="0" width="800px" height="350px">
.......
My problem is when the rule condition is false, it just shows and disappears in a fraction of second. How can i reduce it.
Since your ModalPopupExtender's TargetID is your LinkButton Id
, irrespective of the RULE, it will always show even before that RULE is checked. The solution is to add a HiddenField
and pass its ID as TargetID to ModalPopupExtender. This way you can check the RULE when LinkBUtton is clicked and use ModalPopupExtender.Show()
to show the popup.
<asp:HiddenField ID="hdnpop" runat="server" />
<asp:ModalPopupExtender runat="server" ID="modelPopupExtender1" TargetControlID="hdnpop"
PopupControlID="pan_addEdit" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
In LinkButton event,
if(RULE)
{//Do something
modelPopupExtender1.Show()
}
else
{
//Do something else an dont Show()
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.