Hello,
Based on my understanding, you want to do validation in the click event of TargetControl and pop out the ModalPopup if it satisfies the certain conditions.
In this way, we can build a dummy button as the TargetControl.
Please check the below sample.
<head runat="server">
<title>Untitled Page</title>
<style>
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.7;
}
.modalPopup
{
background-color: #ffffdd;
border-width: 3px;
border-style: solid;
border-color: Gray;
padding: 3px;
width: 250px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager runat="Server" ID="ScriptManager1">
</ajaxToolkit:ToolkitScriptManager>
<asp:Button ID="loginButton" runat="server" Text="login" OnClick="loginButton_Click" /><br />
<asp:Button runat="server" ID="hiddenTargetControlForModalPopup" Style="display: none" />
<ajaxToolkit:ModalPopupExtender runat="server" ID="programmaticModalPopup" BehaviorID="programmaticModalPopupBehavior"
TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="programmaticPopup"
BackgroundCssClass="modalBackground" DropShadow="True" RepositionMode="RepositionOnWindowScroll">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel runat="server" CssClass="modalPopup" ID="programmaticPopup" Style="background-color: ##FFFFCC;
display: none; height: 125px; width: 225px; padding: 10px">
content
</asp:Panel>
</form>
</body> protected void loginButton_Click(object sender, EventArgs e)
{
//if( )
programmaticModalPopup.Show();
}
If you want to achieve it asynchronously, you can build an UpdatePanel and set loginButton as Trigger.