Hi akhter,
Check this example. Now please take its reference and correct your code.
HTML
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
.modalBackground
{
background-color: Black;
filter: alpha(opacity=40);
opacity: 0.4;
}
.modalPopup
{
background-color: #FFFFFF;
width: 300px;
border: 3px solid #0DA9D0;
}
.modalPopup .body
{
min-height: 20px;
line-height: 20px;
text-align: center;
padding: 5px;
}
.modalPopup .footer
{
padding: 3px;
}
.modalPopup .button
{
height: 23px;
color: White;
line-height: 23px;
text-align: center;
font-weight: bold;
cursor: pointer;
background-color: #9F9F9F;
border: 1px solid #5C5C5C;
}
.modalPopup td
{
text-align: left;
}
</style>
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mpe" runat="server"
PopupControlID="pnlPopup" TargetControlID="lnkDummy" BackgroundCssClass="modalBackground"
CancelControlID="btnNo">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup" Style="display: none">
<div class="body">Do you want to Save data?</div>
<div class="footer" align="center">
<asp:Button ID="btnYes" runat="server" Text="Yes" OnClick="OnYes" />
<asp:Button ID="btnNo" runat="server" Text="No" />
</div>
</asp:Panel>
Item QTY : <asp:Label ID="lblItemQty" runat="server" Text="6"></asp:Label><br />
Pack QTY : <asp:Label ID="lblPackQty" runat="server" Text="6"></asp:Label><br />
<asp:Button ID="btnSave" runat="server" OnClick="OnSave" Text="Save" />
Code
C#
public void OnSave(object sender, EventArgs e)
{
// Check your condition.
if (lblItemQty.Text == lblPackQty.Text)
{
ModalPopupExtender1.Show();
}
}
public void OnYes(object sender, EventArgs e)
{
//insertbalgv();
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('Record Inserted!')", true);
}
VB.Net
Public Sub OnSave(ByVal sender As Object, ByVal e As EventArgs)
' Check your condition.
If lblItemQty.Text = lblPackQty.Text Then
ModalPopupExtender1.Show()
End If
End Sub
Public Sub OnYes(ByVal sender As Object, ByVal e As EventArgs)
'insertbalgv()
ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "alert('Record Inserted!')", True)
End Sub
Screenshot