使用带有控制数组的popupextendercontrol [英] use of popupextendercontrol with control array

查看:46
本文介绍了使用带有控制数组的popupextendercontrol的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在asp.net中使用Popupextender控件.如果我将其与单个标签或单个控件一起使用,则可以正常工作,但是如果我与控件数组一起使用,则仅适用于最后一个数组控件,而并​​非对所有控件都适用.与控制数组一起使用.请为此提供帮助.
提前谢谢.

这是我的设计代码

Hi,
I am using Popupextender control in asp.net.If i am using it with single label or single control then it works fine but if i am using that with control array it works only for the last array control not for all.I just want to work that with control array.Please help me for that.
Thanks in advance.

This is my design code

<cc1:PopupControlExtender ID="PopupControlExtender1"  runat="server" 

                     PopupControlID="Panel1" 

                    TargetControlID="lblpce" 

                    DynamicControlID="Panel1" 

                    DynamicServiceMethod="GetDynamicContent" Position="bottom"> 
            </cc1:PopupControlExtender>
<asp:Panel ID="Panel1" runat="server">
                                </asp:Panel>
                                        <asp:Label ID="lblpce" runat="server" Text="Label"></asp:Label>


以下是我的服务器代码
该代码用于创建标签数组


Below is my server code
this code is for creating array of labels

private void AddControls(string anyControl, int cNumber)
        {
            switch (anyControl)
            {
                case "lbl": // anyControl = lbl to Add Label
                    {
                        // assign number of controls 
                        lblArray = new System.Web.UI.WebControls.Label[cNumber + 1];
                        for (int i = 0; i < cNumber + 1; i++)
                        {
                            // Initialize one variable
                            lblArray[i] = new System.Web.UI.WebControls.Label();
                            lblArray[i].ID = "Label" + (i + 1).ToString();
                        }
                        break;
                    }
            }
        }



在按钮上单击



on button click

for (int n = 0; n < 49; n++)
          {
              if ((lblArray[n].Text) != "S")
              {
                  if ((lblArray[n].Text) != "A")
                  {
                      if ((lblArray[n].Text) != "")
                      {
                          //adding popextendercontorl
                          PopupControlExtender pce = FindControl("PopupControlExtender1") as PopupControlExtender;
                          string behaviorID = "pce_" + n;
                          pce.BehaviorID = behaviorID;
                          pce.TargetControlID = lblArray[n].ID.ToString();
                          pce.DynamicContextKey = lblArray[n].Text + "-" + ddlmonth.Text + "-" + ddlyear.Text;
                          //Image img = (Image)e.Item.FindControl("Image1");
                          Label lbl = (Label)FindControl(lblArray[n].ID.ToString());
                          string OnMouseOverScript = string.Format("$find('{0}').showPopup();", behaviorID);
                          string  önMouseOutScript = string.Format("$find('{0}').hidePopup();", behaviorID);
                          //img.Attributes.Add("onmouseover", OnMouseOverScript);
                          //img.Attributes.Add("onmouseout", OnMouseOverScript);
                          //lblArray[n].Attributes.Add("onmouseover", OnMouseOverScript);
                          //lblArray[n].Attributes.Add("onmouseout", OnMouseOverScript);
                          lbl.Attributes.Add("onmouseover", OnMouseOverScript);
                          lbl.Attributes.Add("onmouseout", OnMouseOutScript);
                      }
                  }
              }
          }


这是我的网络服务


this is my web service

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
        public static string GetDynamicContent(string contextKey)
        {
            //string constr = "Server=TestServer;Database=SampleDatabase;uid=test;pwd=test;";
            string sConnectionString = null;
            sConnectionString = ConfigurationSettings.AppSettings["jssConnectionString"];
            string query = "SELECT emp_emailid, emp_msg, emp_msgtime FROM tbl_msg where emp_id='501011'";
            OleDbConnection conn1;
            conn1 = new OleDbConnection(sConnectionString);
            OleDbDataAdapter odbpc = new OleDbDataAdapter(query, conn1);
            DataSet dspc = new DataSet();
            odbpc.Fill(dspc, "tbl_msg");
            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='3'>");
            b.Append("<tr><td colspan='3' style='background-color:#336699; color:white;'>");
            b.Append("Product Details"); b.Append("</td></tr>");
            b.Append("<tr><td style='width:80px;'>Employee Email</td>");
            b.Append("<td style='width:80px;'>Message</td>");
            b.Append("<td>Time</td></tr>");
            b.Append("<tr>");
            b.Append("<td>" + dspc.Tables["tbl_msg"].Rows[0][0].ToString() + "</td>");
            b.Append("<td>" + dspc.Tables["tbl_msg"].Rows[0][1].ToString() + "</td>");
            b.Append("<td>" + dspc.Tables["tbl_msg"].Rows[0][2].ToString() + "</td>");
            b.Append("</tr>");
            b.Append("</table>");
            return b.ToString();
        }

推荐答案

find('{0}').showPopup();",behaviorID); 字符串önMouseOutScript= 字符串 .Format("
find('{0}').showPopup();", behaviorID); string önMouseOutScript = string.Format("


find('{0}').hidePopup();",behaviorID); // img.Attributes.Add("onmouseover",OnMouseOverScript); // img.Attributes.Add("onmouseout",OnMouseOverScript); // lblArray [n] .Attributes.Add("onmouseover",OnMouseOverScript); // lblArray [n] .Attributes.Add("onmouseout",OnMouseOverScript); lbl.Attributes.Add(" ,OnMouseOverScript); lbl.Attributes.Add(" ,OnMouseOutScript); } } } }
find('{0}').hidePopup();", behaviorID); //img.Attributes.Add("onmouseover", OnMouseOverScript); //img.Attributes.Add("onmouseout", OnMouseOverScript); //lblArray[n].Attributes.Add("onmouseover", OnMouseOverScript); //lblArray[n].Attributes.Add("onmouseout", OnMouseOverScript); lbl.Attributes.Add("onmouseover", OnMouseOverScript); lbl.Attributes.Add("onmouseout", OnMouseOutScript); } } } }


这是我的网络服务


this is my web service

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
        public static string GetDynamicContent(string contextKey)
        {
            //string constr = "Server=TestServer;Database=SampleDatabase;uid=test;pwd=test;";
            string sConnectionString = null;
            sConnectionString = ConfigurationSettings.AppSettings["jssConnectionString"];
            string query = "SELECT emp_emailid, emp_msg, emp_msgtime FROM tbl_msg where emp_id='501011'";
            OleDbConnection conn1;
            conn1 = new OleDbConnection(sConnectionString);
            OleDbDataAdapter odbpc = new OleDbDataAdapter(query, conn1);
            DataSet dspc = new DataSet();
            odbpc.Fill(dspc, "tbl_msg");
            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='3'>");
            b.Append("<tr><td colspan='3' style='background-color:#336699; color:white;'>");
            b.Append("Product Details"); b.Append("</td></tr>");
            b.Append("<tr><td style='width:80px;'>Employee Email</td>");
            b.Append("<td style='width:80px;'>Message</td>");
            b.Append("<td>Time</td></tr>");
            b.Append("<tr>");
            b.Append("<td>" + dspc.Tables["tbl_msg"].Rows[0][0].ToString() + "</td>");
            b.Append("<td>" + dspc.Tables["tbl_msg"].Rows[0][1].ToString() + "</td>");
            b.Append("<td>" + dspc.Tables["tbl_msg"].Rows[0][2].ToString() + "</td>");
            b.Append("</tr>");
            b.Append("</table>");
            return b.ToString();
        }


这篇关于使用带有控制数组的popupextendercontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆