0 Replies - 12625 Views - Last Post: 15 October 2011 - 07:38 AM Rate Topic: -----

#1 drilli   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 105
  • Joined: 26-May 09

Two PopUpControl Extender in one aspx page

Posted 15 October 2011 - 07:38 AM

Hi! I have two gridView controls in my aspx page and in first column(TemplateField) of these GV controls i have ImageButtons.

In each image button of each gridView I have a popUpControlExtender :

1.First Grid View (GVProduktet):
ImageButton1 with PopUpControlExtender; like this:
<asp:TemplateField HeaderText="Foto">
                            <ItemTemplate>
                                <asp:ImageButton ID="ImageButton1" runat="server" 
                                    ImageUrl='<%# "Handler1.ashx?id= " + Eval("Shifra") %>' 
                                    
                                    
                                    onclick="ImageButton1_Click" onclientclick="this.disabled=true;__doPostBack(this.name,'');" />
                                <cc1:PopupControlExtender ID="ImageButton1_PopupControlExtender" runat="server" 
                                    DynamicServicePath="" Enabled="True" ExtenderControlID="" 
                                                    PopupControlID="Panel3" TargetControlID="ImageButton1" 
                                                    DynamicContextKey='<%# Eval("Shifra") %>' DynamicControlID="Panel3" 
                                                    DynamicServiceMethod="GetDynamic" Position="Bottom">
                                </cc1:PopupControlExtender>
                            </ItemTemplate>
                        </asp:TemplateField>



with code behind:
protected void GVProduktet_RowCreated(object sender, GridViewRowEventArgs e)
        {   
            
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                PopupControlExtender pce = e.Row.FindControl("ImageButton1_PopupControlExtender") as PopupControlExtender;

                string behaviorID = "pce_" + e.Row.RowIndex;
                pce.behaviorID = behaviorID;


                Image img = (Image)e.Row.FindControl("ImageButton1");
                
                

                string onmouseoverScript = string.Format("$find('{0}').showPopup();", behaviorID);
                string onmouseoutScript = string.Format("$find('{0}').hidePopup();", behaviorID);

                img.Attributes.Add("onmouseover", onmouseoverScript);
                img.Attributes.Add("onmouseout", onmouseoutScript);
            }
        }



 [System.Web.Services.WebMethod(),
   System.Web.Script.Services.ScriptMethodAttribute()]
        public static String GetDynamic(string contextKey)
        {

            StringBuilder b = new StringBuilder();
            String url = "Handler1.ashx?id=" + contextKey.Trim();
            b.Append("<FONT COLOR = 'blue'>");
            b.Append("<img src=");
            b.Append(url);
            b.Append(" alt='' width='250px' height='200px'border ='2'>");
            b.Append("</FONT>");

            return b.ToString();

        }




2.Second Grid View (GVShport):
Image1 with PopUpControlExtender like this:

<ItemTemplate>
                                                <asp:Image ID="Image1" runat="server" 
                                                ImageUrl='<%# "Handler3.ashx?id= " + Eval("Shifra") %>' Height="80px" 
                                                    Width="84px" />
                                                <cc1:PopupControlExtender ID="Image1_PopupControlExtender" runat="server" 
                                                    DynamicServicePath="" Enabled="True" ExtenderControlID="" 
                                                    PopupControlID="Panell1" TargetControlID="Image1" 
                                                    DynamicContextKey='<%# Eval("Shifra") %>' DynamicControlID="Panell1" 
                                                    DynamicServiceMethod="GetDynamicContent" Position="Bottom">
                                                </cc1:PopupControlExtender>
                                            </ItemTemplate>



and code behind:

protected void GVShport_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                PopupControlExtender pce = e.Row.FindControl("Image1_PopupControlExtender") as PopupControlExtender;

                string behaviorID = "pce_" + e.Row.RowIndex;
                pce.behaviorID = behaviorID;


                Image img = (Image)e.Row.FindControl("Image1");

                string onmouseoverScript = string.Format("$find('{0}').showPopup();", behaviorID);
                string onmouseoutScript = string.Format("$find('{0}').hidePopup();", behaviorID);

                img.Attributes.Add("onmouseover", onmouseoverScript);
                img.Attributes.Add("onmouseout", onmouseoutScript);
            }
        }



[System.Web.Services.WebMethod(),
    System.Web.Script.Services.ScriptMethodAttribute()]
        //[System.Web.Services.WebMethod()]
        public static string GetDynamicContent(string contextKey)
        {

            string constr = Klasat.ConnectionString.getConnectionString();
            //string constr = "Server=TestServer;Database=SampleDatabase;uid=test;pwd=test;";
            //string query = "SELECT Cmimi, UnitsInStock, Description FROM Products WHERE ProductID = " + contextKey;

            //SqlDataAdapter da = new SqlDataAdapter(query, constr);

            DataTable table = LidhjetMeDatabaze.MerrNgaShportaMeID(IDUser, contextKey);

            //da.Fill(table);

            StringBuilder b = new StringBuilder();

            b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; ");
            b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='5'>");

            b.Append("<tr><td colspan='5' style='background-color:#336699; color:white;'>");
            b.Append("<b>Detajet e Produktit</b>"); b.Append("</td></tr>");
            b.Append("<tr><td style='width:80px; color:black'><b>Shifra</b></td>");
            b.Append("<td style='width:80px; color:black'><b>Sasia</b></td>");
            b.Append("<td style='width:80px; color:black'><b>Cmimi</b></td>");
            b.Append("<td style='width:80px; color:black'><b>Cmimi/T</b></td>");
            b.Append("<td style='width:80px; color:black'><b>Kategoria</b></td></tr>");

            b.Append("<tr>");
            b.Append("<td>" + table.Rows[0]["Shifra"].ToString() + "</td>");
            b.Append("<td>" + table.Rows[0]["Sasia Ne Shporte"].ToString() + "</td>");
            b.Append("<td>" + table.Rows[0]["Cmimi Per Njesi"].ToString() + "</td>");
            b.Append("<td>" + table.Rows[0]["Cmimi Total"].ToString() + "</td>");
            b.Append("<td>" + table.Rows[0]["Kategoria"].ToString() + "</td>");
            b.Append("</tr>");

            b.Append("</table>");

            return b.ToString();
        }



as you can see I am using GetDynamicContet(String contentKey) for my second GridView and GetDynamic(String contextKey) for my firs GridView but when i execute then the two GridViews are always calling only the GetDynamic(String contextKey).The firs GridView should call GetDynamic and the second should call GetDynamicContent:

I Don`t know where is the problem.

I Hope you understand what I am asking!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1