jQuery Dialog Modal Popup Window Not Working in Child Pages

Last Reply 5 days ago By dharmendr

Posted 6 days ago

I am using Code From  https://www.aspsnippets.com/Articles/Display-GridView-Row-details-inside-jQuery-Dialog-Modal-Popup-in-ASPNet.aspx

Its working fine Without master page but with master page its not working  Please Help me 

<%@ Page Title="" Language="C#" MasterPageFile="~/MainMdi.master" CodeFile="TEST002.aspx.cs" Inherits="TEST002" %>


<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style type="text/css">
       
        body
        {
            font-family: Arial;
        }
        table
        {
            border: 1px solid #ccc;
            border-collapse: collapse;
            background-color:#fff;
            font-size: 10pt !important;
             font-family: Arial !important;
        }
        table th
        {
            background-color: #B8DBFD;
            color: #333;
            font-weight: bold;
        }
        table th, table td
        {
            padding: 5px;
            border: 1px solid #ccc;
        }
        table, table table td
        {
            border: 0px solid #ccc;
        }
    </style>
  

   
    
        <asp:updatepanel id="UpdatePanel1" runat="server">
            <ContentTemplate>

                                         <telerik:RadComboBox  RenderMode="Lightweight" AutoPostBack="true" ID="cmbuom" runat="server" ClientDataSourceID="RadClientDataSource1" 
            ShowMoreResultsBox="True"   ItemsPerRequest="10" EnableVirtualScrolling="True" Width="100%" Filter="Contains">
                                <Items>
                                    <telerik:RadComboBoxItem runat="server" Text="COTTON" Value="1" />    
                                    <telerik:RadComboBoxItem runat="server" Text="KG" Value="2" />
                                     <telerik:RadComboBoxItem runat="server" Text="LITER" Value="3" />    
                                    <telerik:RadComboBoxItem runat="server" Text="TIN" Value="4" />                                       
                                </Items>
        </telerik:RadComboBox> 
                <asp:Button ID="btnShowPopup" runat="server" Text="Button" />
                     <asp:TextBox ID="TextBox2"    oninput="FindValueLevel41()"  onkeyup="javascript:Search_Gridview(this, 'GridView1')" runat="server"></asp:TextBox> 
       <asp:TextBox ID="TextBox3"  onkeyup="javascript:Search_Gridview(this, 'GridView1')" runat="server"></asp:TextBox> 
       <asp:TextBox ID="TextBox4"  onkeyup="javascript:Search_Gridview(this, 'GridView1')" runat="server"></asp:TextBox> 
                   </ContentTemplate>
            </asp:updatepanel>
  
    <div id="dialog"  style="display: none"   >
     
         Search :<asp:TextBox ID="TextBox1"   onkeyup="javascript:Search_Gridview(this, 'GridView1')" runat="server"></asp:TextBox> 

        <asp:RadioButton id="Rcode" runat="server" Text="Code" GroupName="measurementSystem"></asp:RadioButton>
<asp:RadioButton id="Rname" runat="server" text="Name" Checked="true" GroupName="measurementSystem"></asp:RadioButton>
<div  style="height: 200px; overflow: auto" >
        <asp:GridView ID="GridView1" PageSize="2000"    runat="server" AutoGenerateColumns="false" OnPageIndexChanging="OnPageIndexChanging"
          AllowPaging="true">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID"    ItemStyle-CssClass="ID" ItemStyle-Width="80" />            
                <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
                <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
                  <asp:TemplateField>
                    <ItemTemplate>
                        <a href="#" class="editsearch">Select</a>
                  
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
          
        </asp:GridView>
        </div>
    </div>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
    <link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
        rel="stylesheet" type="text/css" />

 
    <script type="text/javascript">
        var levelcombo;
        $(function () {
          
            $("input[id*='btnShowPopup']").on("click", function ()
            {
             
            
                alert("Aya");
                $("#dialog").dialog("open");
                    return false;
           
              //  $('#dialog').modal('show');
                //$('.dialog').dialog({
                  
                //    height: 200,
                //    modal: true
                //});


          
                ShowPopup();
                return false;
            });
        });
       function FindValueLevel41()
        {             var combo = $find("<%= cmbuom.ClientID %>");
                combo.findItemByValue(document.getElementById("<%=TextBox2.ClientID%>").value).select(); 
            }
        $("#TextBox2").keydown(function (event) {
            if (event.which == 113) {
                levelcombo = 2;
                ShowPopup();
                $(function () {
                    $.ajax({
                        type: "POST",
                        url: "CS.aspx/GetCustomers",
                        data: '{}',
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: OnSuccess,
                        failure: function (response) {
                            alert(response.d);
                        },
                        error: function (response) {
                            alert(response.d);
                        }
                    });
                });

                function OnSuccess(response) {
                    var xmlDoc = $.parseXML(response.d);
                    var xml = $(xmlDoc);
                    var customers = xml.find("Table");
                    var row = $("[id*=GridView1] tr:last-child").clone(true);
                    $("[id*=GridView1] tr").not($("[id*=GridView1] tr:first-child")).remove();
                    $.each(customers, function () {
                        var customer = $(this);
                        $("td", row).eq(0).html($(this).find("ID").text());
                        $("td", row).eq(1).html($(this).find("Name").text());
                        $("td", row).eq(2).html($(this).find("Country").text());
                        $("[id*=GridView1]").append(row);
                        row = $("[id*=GridView1] tr:last-child").clone(true);
                    });
                }
                return false;
            }
        });
            $("#TextBox3").keydown(function (event) {
                if (event.which == 113) {
                    levelcombo = 3;            
                    ShowPopup();
                    return false;
                }
            });
                $("#TextBox4").keydown(function (event) {
                    if (event.which == 113) {
                        levelcombo = 4;  
                        ShowPopup();
                        return false;
              }
        });
         function Search_Gridview(strKey, strGV) {
            $("#<%=GridView1.ClientID%> tr:has(td)").hide(); 
            var iCounter = 0;
            var sSearchTerm = $('#<%=TextBox1.ClientID%>').val(); 
           if(sSearchTerm.length == 0) 
            {  
                $("#<%=GridView1.ClientID%> tr:has(td)").show(); 
              return false;
           }
             var filter;
             if ($("#<%=Rname.ClientID%>").is(':checked')) {
                 filter = 2;
             }
             else {
                 filter = 1;
             }  
             $("#<%=GridView1.ClientID%> td:nth-child("+filter+")").each(function () 
             {
                var cellText = $(this).text().toLowerCase();
                if(cellText.indexOf(sSearchTerm.toLowerCase()) >= 0) 
                {    
                    $(this).parent().show();            
                    iCounter++;   
                    return true;
                    
                }
              
            });

      
            }
        $(function () {

            $("body").on("click", ".editsearch", function () {
                var textbox;
                if (levelcombo == 2) {
                    textbox = $("[id*=TextBox2]");
                }
                else if (levelcombo == 3)
                {
                    textbox = $("[id*=TextBox3]");
                }
                else if (levelcombo == 4) {
                    textbox = $("[id*=TextBox4]");
                }
                textbox.val($.trim($(".ID", $(this).closest("tr")).html()));
                textbox.trigger("input");
                return false;
            });

        });
  
        function ShowPopup() {
       

            $("[id*=dialog]").dialog({
              //$("#dialog").dialog({
                title: "Chart Of Account",
                width: 600,
                buttons: {
                    Ok: function () {
                        $(this).dialog('close');
                    }
                },
                modal: true
              });
              
        }
    </script>

         
</asp:Content>

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Services;

public partial class TEST002 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {


            // this.BindGrid();
            DataTable dummy = new DataTable();
            dummy.Columns.Add("ID");
            dummy.Columns.Add("Name");
            dummy.Columns.Add("Country");
            dummy.Rows.Add();
            GridView1.DataSource = dummy;
            GridView1.DataBind();
        }
    }

    private void BindGrid()
    {
        string constr = ConfigurationManager.ConnectionStrings["SoftaxeWebconnectingStr"].ConnectionString;
        using (SqlConnection con = new SqlConnection(constr))
        {
            using (SqlCommand cmd = new SqlCommand("SELECT ID , Name, Country FROM Customers"))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    cmd.Connection = con;
                    sda.SelectCommand = cmd;
                    using (DataTable dt = new DataTable())
                    {
                        sda.Fill(dt);
                        GridView1.DataSource = dt;
                        GridView1.DataBind();
                    }
                }
            }
        }
    }
  
        
    
    private static DataSet GetData(SqlCommand cmd)
    {
      
        string strConnString = ConfigurationManager.ConnectionStrings["SoftaxeWebconnectingStrC"].ConnectionString;
        using (SqlConnection con = new SqlConnection(strConnString))
        {
            using (SqlDataAdapter sda = new SqlDataAdapter())
            {
                cmd.Connection = con;
                sda.SelectCommand = cmd;
                using (DataSet ds = new DataSet())
                {
                    sda.Fill(ds);
                    return ds;

                }
            }
        }
    }
    [WebMethod]
    public static string GetCustomers()
    {
       
        string query = "SELECT ID , Name, Country FROM Customers";
        SqlCommand cmd = new SqlCommand(query);
        return GetData(cmd).GetXml();
    }
    protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        this.BindGrid();
        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup();", true);
    }

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

 

You are viewing reply posted by: Shahzad786 6 days ago.
Posted 6 days ago

Hi Andrea

this not Work for me .

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html