Solved

ModalPopupExtender not working from code behind

Posted on 2014-04-22
7
608 Views
Last Modified: 2014-04-22
Hi all,

I'm trying to invoke a modal popup on a gridview to change user passwords. The modal isn't appearing though? can anyone tell me what I am doing wrong here;

    <asp:HyperLink ID="DummyButton" runat="server" Style="display: none;" />

    <asp:ModalPopupExtender ID="PasswordModalPopupExtender" TargetControlID="DummyButton" PopupControlID="PasswordPopup" runat="server" DropShadow="true" Enabled="true">
    </asp:ModalPopupExtender>
    
    <asp:Panel id="PasswordPopup" runat="server" style="display:none;">
        <asp:ChangePassword ID="ChangePasswordControl" runat="server"></asp:ChangePassword>
    </asp:Panel>

Open in new window


and on the gridview i am capturing the  OnSelectedIndexChanged="OnSelectedIndexChanged"

        ChangePasswordControl.UserName = UserList.SelectedRow.Cells[1].Text;
        FeedbackLabel.Text = "Changing Password for " + UserList.SelectedRow.Cells[1].Text;
        PasswordModalPopupExtender.Show();

Open in new window


now all is firing and the FeedbackLabel is displaying the correct info but the modal doesnt appear?
0
Comment
Question by:flynny
  • 4
  • 3
7 Comments
 
LVL 7

Expert Comment

by:Utkarsh Kulkarni
Comment Utility
It may be invoking the popup. Just to make sure it get displaying or not, set BackgroundCssClass property.
Also, if it is inside update panel, make sure, both (grid and ModalPopupExtender) should be in same update panel.
0
 

Author Comment

by:flynny
Comment Utility
Thanks for the reply.

Will not setting the BackgroundCssClass cause issues? Could you suggest what I should put in here for testing?

The modal is not inside anupdate panel and is just in a standard aspx page with a masterpage.
0
 
LVL 7

Expert Comment

by:Utkarsh Kulkarni
Comment Utility
BackgroundCssClass is an optional attribute. But the css or default setting can do this.
Also, try to access the page in FF & open the Java console to see is there any script error.
Sample CSS

.popup_block{
      display: none; /*--hidden by default--*/
      float: left;
      font-size: 1.2em;
      position: fixed;
      top: 9%; left: 30%;
      z-index: 99999;      
}
.modal_Background
{
      background-color:#CCCCCC;
      filter:alpha(opacity=90);
      opacity:0.9;
      }
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:flynny
Comment Utility
as far as I can see there are no errors?

    <asp:ModalPopupExtender ID="PasswordModalPopupExtender" TargetControlID="DummyButton" PopupControlID="PasswordPopup" BackgroundCssClass="tmodal_Background" runat="server" DropShadow="true" Enabled="true">
    </asp:ModalPopupExtender>
    
    <asp:Panel id="PasswordPopup" runat="server" CssClass="tpopup_block">
        <asp:ChangePassword ID="ChangePasswordControl" runat="server"></asp:ChangePassword>
    </asp:Panel>

Open in new window


and css is;

.tpopup_block{
      display: none; /*--hidden by default--*/
      float: left;
      font-size: 1.2em;
      position: fixed;
      top: 9%; left: 30%;
      z-index: 99999;      
}
.tmodal_Background
{
      background-color:#CCCCCC;
      filter:alpha(opacity=90);
      opacity:0.9;
      } 

Open in new window


if I user firebug I can drill down and see the panel is being rendered?

any idea?
0
 
LVL 7

Expert Comment

by:Utkarsh Kulkarni
Comment Utility
You can check using firebug.
What AjaxControl Toolkit version are you using ?
0
 
LVL 7

Accepted Solution

by:
Utkarsh Kulkarni earned 500 total points
Comment Utility
Hi,

here is the sample code
 <style>
            .tpopup_block {
                display: none; /*--hidden by default--*/
                float: left;
                font-size: 1.2em;
                position: fixed;
                top: 20%;
                left: 30%;
                z-index: 99999;
                color: #ff0000;
            }

            .tpopup_block_click {
                float: left;
                font-size: 1.2em;
                position: fixed;
                top: 20%;
                left: 30%;
                z-index: 99999;
                color: #ff0000;
            }

            .tmodal_Background {
                background-color: #CCCCCC;
                filter: alpha(opacity=90);
                opacity: 0.9;
            }
        </style>
        <div>
            <asp:ScriptManager runat="server" ID="sm"></asp:ScriptManager>
            <asp:Button ID="bbb" runat="server" OnClick="bbb_Click" Text="Test" />
            <asp:HyperLink ID="DummyButton" runat="server" Style="display: none;" />
            <cc1:ModalPopupExtender ID="PasswordModalPopupExtender" TargetControlID="DummyButton" PopupControlID="PasswordPopup" BackgroundCssClass="tmodal_Background" runat="server" DropShadow="true" Enabled="true">
            </cc1:ModalPopupExtender>
            <asp:Panel ID="PasswordPopup" runat="server" CssClass="tpopup_block">
                <h1>Sample Text</h1>
            </asp:Panel>
        </div>

Open in new window


protected void bbb_Click(object sender, EventArgs e)
        {
            PasswordPopup.CssClass = "tpopup_block_click";
            PasswordModalPopupExtender.Show();
        }

Open in new window


Check this on single page first & then modify for Master Page / Content place holder
0
 

Author Comment

by:flynny
Comment Utility
hi there.

this still was not working. So as I am really only showing this from the server side I have just removed the popupcontrol and set a panel to be visible=true on the click.

this works well and removes the bloated popupextender control.

thanks for all the help though.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now