1
我有一個GridView,在我的GridView中,我將Linkbuttons添加到某個列。我想要做的是當你點擊在我的GridView中創建的LinkButton時,我想要顯示我的ModalPopupExtender。在的RowDataBound創建ModalPopupExtender Gridview
的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
JavaScript來顯示我的ModalPopupExtender:
<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>
的問題是什麼,當我點擊LinkButton的我ModalPopupExtender呢顯示,但在一秒鐘內它再次消失。不知道是否是因爲PostBack。