1

我有一个 Gridview,在我的 GridView 中,我将 Linkbuttons 添加到某个列。我想要做的是当您单击在我的 GridView 中创建的 LinkBut​​ton 时,我希望我的 ModalPopupExtender 显示。

在 RowDataBound 中创建的 LinkBut​​ton:

Private Sub grdDetails_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdDetails.RowDataBound
Try
  Try
    If Not iColAttachent Is Nothing Then
      For Each i In iColAttachent
        If e.Row.DataItem(i - 1).ToString.Trim.Length > 0 Then
          Dim c As New TableCell
          Dim LB As New LinkButton
          Dim strBookNo As String = e.Row.DataItem(i - 1).ToString

          ' Create link
          LB.ID = "LB_" & strBookNo
          LB.Text = strBookNo.Substring(strBookNo.IndexOf("_") + 1)
          LB.ToolTip = "Click to change book number"
          LB.Attributes.Add("AutoPostBack", "False")
          LB.Attributes.Add("OnClick", "ShowModal()")
          'HL.Attributes.Add("runat", "server")

          e.Row.Cells().RemoveAt(i)
          e.Row.Cells().AddAt(i, c)
          c.Controls.Add(LB)
        End If
      Next
    End If
  Catch
    ' nothing to do
  End Try
Catch ex As Exception

End Try
End Sub

用于显示我的 ModalPopupExtender 的 JavaScript:

<script language="javascript" type="text/javascript">
    function ShowModal() {
        var modal = $find('ModalPopupExtender1');
        modal.show();
    }
</script>

模态弹出扩展器

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1" DropShadow="true"
            BackgroundCssClass="modalBackground" CancelControlID="cmdCancel" BehaviorID="ModalPopupExtender1" Drag="true">

            </asp:ModalPopupExtender>

问题是当我单击我的 ModalPopupExtender 确实显示的 LinkBut​​ton 但在一秒钟内它又消失了。不确定是不是因为 PostBack。

4

1 回答 1

0

通过添加链接按钮并将其分配给 modalpopup 解决了该问题。也许不是最好的方法,但它确实有效。

于 2013-04-23T14:28:27.593 回答