Ajax 带Gridview的ModalPopupXtender
我有一个Gridview,在Gridview中,我向某个列添加链接按钮。我要做的是,当您单击在我的GridView中创建的链接按钮时,我希望我的ModalPopupXtender显示出来 在RowDataBound中创建的链接按钮:Ajax 带Gridview的ModalPopupXtender,ajax,modalpopupextender,Ajax,Modalpopupextender,我有一个Gridview,在Gridview中,我向某个列添加链接按钮。我要做的是,当您单击在我的GridView中创建的链接按钮时,我希望我的ModalPopupXtender显示出来 在RowDataBound中创建的链接按钮: Private Sub grdDetails_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdDet
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
用于显示我的ModalPopupXtender的JavaScript:
<script language="javascript" type="text/javascript">
function ShowModal() {
var modal = $find('ModalPopupExtender1');
modal.show();
}
</script>
函数showmodel(){
var modal=$find('ModalPopupExtender1');
modal.show();
}
ModalPopupExtender
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1" DropShadow="true"
BackgroundCssClass="modalBackground" CancelControlID="cmdCancel" BehaviorID="ModalPopupExtender1" Drag="true">
</asp:ModalPopupExtender>
当我单击链接按钮时,问题是我的ModalPopupXtender确实会显示,但在一秒钟内它又消失了。不确定是否是因为回发。通过添加链接按钮并将其分配给modalpopup修复了该问题。也许这不是最好的方法,但它是有效的