我有一个Gridview,在我的GridView中我将Linkbuttons添加到某个列。我想要做的是当你点击我的GridView中创建的LinkButton时,我希望我的ModalPopupExtender显示。
在RowDataBound中创建的LinkButton:
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>
ModalPopupExtender
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1" DropShadow="true"
BackgroundCssClass="modalBackground" CancelControlID="cmdCancel" BehaviorID="ModalPopupExtender1" Drag="true">
</asp:ModalPopupExtender>
当我点击我的ModalPopupExtender确实显示的LinkButton时会出现什么问题但是在一秒之内它会再次消失。不确定是否是因为PostBack。
答案 0 :(得分:0)
通过添加链接按钮并将其分配给modalpopup来解决此问题。也许不是最好的方法,但它有效。