在 gridview 中,我有一个 TemplateField,其中包含每行的超链接。
<asp:TemplateField>
<HeaderStyle CssClass="gridHeader" HorizontalAlign="center" ForeColor="White" BackColor="Gray" VerticalAlign="Middle" />
<ItemStyle CssClass="gridItem" />
<ItemTemplate>
<asp:HyperLink id="hyplnkAuditTrail" runat="server" href="##">Audit Trail</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
和后面的代码:
Protected Sub gvHotelMarkup_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvHotelMarkup.RowDataBound
Try
If e.Row.RowType = DataControlRowType.DataRow Then
Dim hlnkAuditTrail As HyperLink = e.Row.FindControl("hyplnkAuditTrail")
hlnkAuditTrail.Attributes.Add("onclick", "audittrail(" & e.Row.DataItem("HotelId") & "," & ddlGS.SelectedValue & ");")
End If
Catch ex As Exception
lblErrMessage.Message = ex.Message()
End Try
End Sub
和 javascript 链接
<script type ="text/javascript" language="javascript" >
function audittrail(HotelId,Source)
{ var strUrl = "frmGDSAuditTrail.aspx?HotelId=" + HotelId+"&Provider=" + Source;
var width = 700;
var height = 300;
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height);
window.open(strUrl,null,
'width='+ width +','+
'height='+ height+','+
'top=' + top +',' +
'left=' + left + ',' +
'status=yes,' +
'toolbar=no,' +
'menubar=yes,' +
'location=no,' +
'scrollbars=yes,' +
'resizable=yes'
);
}
但是当点击链接时,新页面不会显示。
我使用了断点,但超链接的属性限制得很好。