Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

ModalPopupExtender Show() not firing

$
0
0

I know this issue has been posted on many different occasions. I've looked so many websites to find a solution to this issue, however none of those solutions have helped me find the correct answer to this.

My code is based on this guy's website >> http://mattberseth.com/blog/2007/07/modalpopupextender_example_for.html

I have a GridView that sources its data from the SqlDataSource1. Within that GridView, in the first column I have View buttons that should show the details of each row in the ModalPopupExtender1. I set its TargetControlID to btnShowPopup, which is not visible but as I say "not visible" doesn't mean it's set Visible="false" but it is set style="display:none" (I found this is the way people do).

The problem is even when I click on one of the View buttons, the ModalPopup doesn't appear. In fact, when I click the button, nothing happens.

On the Visual Basic, I don't see any error messages nor exception handlers after clicking on the View button.

Any help would be appreciated. Thank you in advance!

My code:

<aspx>

<%@ Page Title="" Language="C#" MasterPageFile="~/Main/MasterPage.master" AutoEventWireup="true" CodeFile="SearchAcquisition.aspx.cs" Inherits="PosStock" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %><asp:Content ID="Content1" ContentPlaceHolderID="headContent" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="Maincontent" Runat="Server"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><div class="contentboxh"><h2 class="hpos">Acquisition Search</h2><br /><br /><h2 class="h4" style="text-align: left">Search</h2><br /><asp:TextBox ID="SearchField" runat="server" Width="350px" Height="30px" OnTextChanged="SearchField_TextChanged"></asp:TextBox><asp:Button ID="SearchButton" runat="server" Text="Search" Height="26px" OnClick="SearchButton_Click" BackColor="#7AB800" CssClass="searchbutton" /></div><div class="contentboxh"><asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [acquisition_ID], [acquisition_name], [acquisition_qty], [acquisition_cost], [acquisition_date], [acquisition_status] FROM [Acquisition] WHERE [acquisition_ID] = @acquisition_ID"
                SelectCommandType="Text" CancelSelectOnNullParameter="true" ConnectionString="<%$ ConnectionStrings:MJENTAConnectionString %>"></asp:SqlDataSource><asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:GridView ID="GridView1" runat="server" DataKeyNames="acquisition_ID" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PageSize="10" Width="95%"><Columns><asp:TemplateField ControlStyle-Width="50px" HeaderStyle-Width="60px"><ItemTemplate><asp:Button ID="btnViewDetails" runat="server" Text="Details" CommandName="View" OnClick="BtnViewDetails_Click" /></ItemTemplate></asp:TemplateField><asp:BoundField DataField="acquisition_ID" HeaderText="ID" SortExpression="acquisition_ID" ReadOnly="true" /><asp:BoundField DataField="acquisition_name" HeaderText="Name" SortExpression="acquisition_name" ReadOnly="true" /><asp:BoundField DataField="acquisition_qty" HeaderText="Quantity" SortExpression="acquisition_qty" ReadOnly="true" /><asp:BoundField DataField="acquisition_cost" HeaderText="Cost" SortExpression="acquisition_cost" ReadOnly="true" /><asp:BoundField DataField="acquisition_date" HeaderText="Date Added" SortExpression="acquisition_date" ReadOnly="true" /><asp:BoundField DataField="acquisition_status" HeaderText="Status" SortExpression="acquisition_status" ReadOnly="true" /></Columns></asp:GridView></ContentTemplate></asp:UpdatePanel><asp:Button ID="btnShowPopup" runat="server" style="display:none" /><asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlPopup"
                            CancelControlID="btnClose" BackgroundCssClass="modalBackground" /><asp:Panel ID="pnlPopup" runat="server" CssClass="detail" Width="500px" style="display:none"><asp:UpdatePanel ID="updPnlCustomerDetail" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:Label ID="lblCustomerDetail" runat="server" Text="Detail" BackColor="LightBlue" Width="95%" /><asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Edit" Width="95%" BackColor="White" /></ContentTemplate></asp:UpdatePanel><div align="right" style="width:95%"><asp:Button ID="btnSave" runat="server" Text="Save" Width="50px" /><asp:Button ID="btnClose" runat="server" Text="Close" Width="50px" /></div></asp:Panel></div></asp:Content>

<Code behind>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data;

public partial class PosStock : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void BtnViewDetails_Click(object sender, EventArgs e)
    {
        Button btnDetails = sender as Button;
        GridViewRow row = (GridViewRow)btnDetails.NamingContainer;

        this.SqlDataSource1.SelectParameters.Clear();
        this.SqlDataSource1.SelectParameters.Add("acquisition_ID", Convert.ToString(this.GridView1.DataKeys[row.RowIndex].Value));
        this.DetailsView1.DataSource = this.SqlDataSource1;
        this.DetailsView1.DataBind();

        this.updPnlCustomerDetail.Update();
        ModalPopupExtender1.Show();

    }
    protected void SearchField_TextChanged(object sender, EventArgs e)
    {

    }
    protected void SearchButton_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MJENTAConnectionString"].ToString());

        SqlCommand cmd;
        
        String str = "SELECT acquisition_ID, acquisition_name, acquisition_qty, acquisition_cost, acquisition_date, acquisition_status FROM Acquisition WHERE (acquisition_name like '%' + @search + '%')";
        cmd = new SqlCommand(str, con);
        cmd.Parameters.Add("@search", SqlDbType.NVarChar).Value = SearchField.Text;
        con.Open();
        cmd.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        DataSet ds = new DataSet();
        da.Fill(ds, "acquisition_name");
        GridView1.DataSource = ds;
        GridView1.DataBind();
        con.Close();
    }
}


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>