locked
ModalPopup Extender RRS feed

  • Question

  • User2045381035 posted

    Dear *.*

    i have a modalpopup extender with gridview control that show's record, a textbox control (use for search key) and a button control.

    this is my problem, when i input a value on a textbox and then clicked the button search, the modalpopup extender close...

    it should show the results on a gridview control....

    anybody help?

    Thursday, August 13, 2015 2:05 PM

Answers

All replies

  • User-1672470423 posted

    Are you calling Show() method on search button click. ex. modalpopup extender ID = "popup",

    popup.Show();

    You can also check below link.

    http://forums.asp.net/t/1360105.aspx?Modal+Popup+Extender+server+side+Show+does+not+work

    Share us your code if it does not help.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 13, 2015 2:42 PM
  • User61956409 posted

    Hi nergan,

    this is my problem, when i input a value on a textbox and then clicked the button search, the modalpopup extender close...

    it should show the results on a gridview control....

    As Sumit.Pokhriyal said, we could call Show() method to open ModalPopupExtender from code behind, the following sample is for your reference.

    <asp:Button ID="btnopen" runat="server" Text="OpenModal" />
    <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnopen" PopupControlID="Panel1" BackgroundCssClass="bgcss"></asp:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server">
        <asp:TextBox ID="txtname" runat="server"></asp:TextBox><asp:Button ID="btnsearch" runat="server" Text="Search" OnClick="btnsearch_Click" />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" />
                <asp:BoundField DataField="Values" HeaderText="Values" SortExpression="Values" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [ChartInfo]"></asp:SqlDataSource>
    </asp:Panel>
    
    
    protected void btnsearch_Click(object sender, EventArgs e)
    {
        string name = txtname.Text.ToString();
        if (name != "")
        {
            SqlDataSource1.SelectCommand = "SELECT * FROM [ChartInfo] where [Name] = '" + name + "'";
            SqlDataSource1.DataBind();
            GridView1.DataBind();
    
            //call Show() method to open ModalPopupExtender
            ModalPopupExtender1.Show();
        }
    }
    

    Best Regards,

    Fei Han



    Thursday, August 13, 2015 11:22 PM
  • User177399542 posted

    You need to show Ajax control toolkit modal popup from code behind event of your button control. Like this:

    protected void btnsearch_Click(object sender, EventArgs e)
    {
    //--- Open modal popup
     IdOfYourModalPopupExtender1.Show();
       
    }
    
    //If you want to close modal popup you can:
    IdOfYourModalPopupExtender1.Hide();

    Friday, August 14, 2015 5:37 AM