activate ModalPopupExtender witheout giving it TargetControlID in asp.net - DOTNET

activate ModalPopupExtender witheout giving it TargetControlID in asp.net

how can i activate a ModalPopupExtender, whiteout giving the TargetControlID a button id in the aspx page (i dont know wiche button will activate the ModalPopupExtender i have a multiple buttons on my page)


you must have one TargetControlID but you can hide it and activate the pop up with a different button:
<div style="display:none;">
<asp:LinkButton runat="server" ID="lbPrivacy" Text="PRIVACY"/>
</div>
<asp:ModalPopupExtender ID="MpePrivacy" runat="server" TargetControlID="lbPrivacy"

<asp:LinkButton runat="server" ID="lbPrivacy2" Font-Underline="true"
CausesValidation="false" OnClick="btMpePrivacy_Click">Privacy</asp:LinkButton>

protected void btMpePrivacy_Click(object sender, EventArgs e)
{
AjaxControlToolkit.ModalPopupExtender modalPop = ((AjaxControlToolkit.ModalPopupExtender)(this.Master.FindControl("ContentPlaceHolder1").FindControl("MpePrivacy")));
modalPop.Show();
}


modalpopupextender not recognising the BackgroundCssClass when using .show()






I am having a problem getting a modalpopupextender to display when using the .show() in code behind.


When using the link button the modal popup works exactly as expected, however when i invoke it from the code behind, the popup is not modal and I can enter data into text box's, click other buttons etc. Note the linkbutton will usually be hidden with style="display:none;".


I am trying to setup the popup to display a message depending upon which button is clicked.


I have copied the code below (removed the extra tables detail to save space).

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FrmTransaction.aspx.cs" Inherits="Cloud9.FrmTransaction" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />

<div runat="server" id="PageDetailDiv" class="pagedetail">
<asp:ValidationSummary runat="server" />

<asp:Table runat="server" HorizontalAlign="Center" Width="80%">
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Label runat="server" ID="lblMsg" CssClass="Msg" EnableViewState="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="trSearch" runat="server">
<asp:TableCell runat="server">
<div align="left">
<asp:Label CssClass="formCapture" Text='Field' runat="server" ID="lblSearchField" AssociatedControlID="tbSearchField" />
<obout:OboutTextBox FolderStyle="Styles/Obout/TextBox" runat="server" ID="tbSearchField" Width="300px" />
<br />
<asp:Label CssClass="formCapture" Text='Lookup' runat="server" ID="lblSearch" AssociatedControlID="tbSearch" />
<obout:OboutTextBox FolderStyle="Styles/Obout/TextBox" runat="server" ID="tbSearch" Width="300px" />
<asp:Button ID="SearchButton" runat="server" Text="Find" CommandName="Search" CausesValidation="False"
OnCommand="btnClick_Search" CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'" />
</div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>

<asp:Table runat="server" HorizontalAlign="Center" Width="80%">
<asp:TableRow ID="trButton" runat="server">
<asp:TableCell>
<div align="center">
<asp:Button id="btnInsert" runat="server" Text="Insert" CommandName="Insert" CausesValidation="True" OnCommand="btnClick_Insert"
CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'"/>
&nbsp;
<asp:Button id="btnUpdate" runat="server" Text="Update" CommandName="Update" CausesValidation="True" OnCommand="btnClick_Update"
CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'"/>
&nbsp;
<asp:Button id="btnDelete" runat="server" Text="Delete" CommandName="Delete" CausesValidation="False" OnCommand="btnClick_Delete"
CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'"/>
&nbsp;
<asp:Button id="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="False" OnCommand="btnClick_Cancel"
CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'"/>
</div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>

<asp:Panel CssClass="modalPopup" runat="server" ID="pnlMessage" >
<asp:Label runat="server" ID = "lblMessg" />
<br />
<asp:Button id="btnOKMessage" Text="OK!" Runat="server" UseSubmitBehavior="false" CausesValidation="false" OnCommand="btnClick_Cancel"
class="btnPgeSmall" onMouseOver="this.className='btnPgeSmallHover'" onMouseOut="this.className='btnPgeSmall'" />
</asp:Panel>

<asp:LinkButton ID="UsedByModal" Text="here" runat="server" />
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="pnlMessage" TargetControlID="UsedByModal"
BackgroundCssClass="modalBackground" CancelControlID="btnOKMessage" OkControlID="btnOKMessage" />
</div>
</asp:Content>
the relevant part of the CSS .....
.modalBackground {
background
-color:Gray;
filter
:alpha(opacityp);
opacity
:0.7;
}

.modalPopup {
background
-color:#F6F6EA;
border
-width:3px;
border
-style:solid;
border
-color:#c0c0c0;
padding
:3px;
width
:50%;
}
I have been looking for an answer for the last 3 days and am now totally stuck. Any help or guidance would be appreciated.
This class is producing right results for me, You can modify it to suit your needs.
.modalBackground
{
background
-color: #000000;
opacity
: .15;
filter
: alpha(opacity=15);
-moz-opacity: .15;
}
Copyright © 2015 DOTNET All Right Reserved