如何使用PopupControlExtender弹出除PANEL之外的ASP.NET控件?

时间:2015-02-17 07:21:00

标签: c# asp.net web-services ajaxcontroltoolkit popupcontrolextender

PopupControlExtender可以弹出许多ASP.NET控件,但只能在Internet上找到面板弹出的示例... 如何弹出其他控件,如gridview?

e.g。我将通过MachineNo从数据库获取DataTable并将DataTable设置为GridView2的数据源。然后我想弹出GridView2,当鼠标悬停在图像按钮上时显示该机器的信息。 如何编写代码?

<asp:GridView ID="GridView1" ...onrowcreated="GridView1_RowCreated">
<Columns>
  <asp:BoundField HeaderText="MachineNo" DataField="MachineNo"/>
  <asp:TemplateField>
    <ItemTemplate>
      <asp:ImageButton ID="ImageButton1" .../>
      <cc1:PopupControlExtender ID="PopupControlExtender1" runat="server" 
           PopupControlID="GridView2" 
           TargetControlID="ImageButtonl" 
           DynamicContextKey='<%# Eval("MachineNo") %>' 
           DynamicControlID="GridView2" 
           DynamicServiceMethod="GetDynamicContent" ???>
      </cc1:PopupControlExtender>
    </ItemTemplate>
  </asp:TemplateField>
</Columns>
</asp:GridView>

<asp:GridView ID="GridView2" ...>...

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e){
if (e.Row.RowType == DataControlRowType.DataRow)
{
    PopupControlExtender PopupControlExtender1 = (PopupControlExtender)e.Row.FindControl("PopupControlExtender1");
    string behaviorID = "PopupControlExtender1_" + e.Row.RowIndex;
    PopupControlExtender1.BehaviorID = behaviorID;
    ImageButton ImageButton1 = (ImageButton)e.Row.FindControl("ImageButton1");

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

    ImageButton1.Attributes.Add("onmouseover", OnMouseOverScript);
    ImageButton1.Attributes.Add("onmouseout", OnMouseOutScript);
}}

1 个答案:

答案 0 :(得分:0)

我刚刚阅读了您的代码。而在我这方面,我成功地通过这种方式显示弹出窗口

> probability(k=14)
[1] 0.2333333