コメント
コメントの投稿
※名前とタイトルが入力されていないコメントでは他のコメントとの区別ができません。
入力されていないコメントには返信しませんのであらかじめご了承くださいませ。
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ListViewTest.aspx.vb" Inherits="ListViewTest.ListViewTest" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>ListViewSample</title>
<link rel="stylesheet" type="text/css" href="~/Styles/Style.css" media="all" />
<script src="Scripts/jquery-1.10.2.min.js"></script>
<script src="Scripts/common.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div class="table-area">
<asp:ListView ID="ListView1" runat="server" ItemPlaceholderID="itemPlaceHolder1">
<LayoutTemplate>
<table>
<thead>
<tr>
<th runat="server" class="id-field">
<label>ID</label>
</th>
<th runat="server" class="link-field">
リンク
</th>
</tr>
</thead>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td runat="server" class="id-field">
<asp:Label ID="lblID" runat="server" Text='<%# (Eval("ID")) %>'></asp:Label>
</td>
<td runat="server" class="link-field">
<asp:HyperLink NavigateUrl="~/ListViewTest.aspx" runat="server">リンク</asp:HyperLink>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</div>
</body>
</html>
$(function () {
//左クリック時の新しいタブやウィンドウを開く場合のフラグ付け
$('.link-field a').click(function (event) {
var keyEvent = event || window.event;
var href = $(this).prop('href').toLowerCase();
//ShiftやCtrlボタンを押しながらクリックした場合
if (keyEvent.ctrlKey ||
keyEvent.shiftKey) {
//クエリ文字列が含まれていない場合は付与
if (href.indexOf('newtab') <= 0) {
$(this).prop('href', href + '?newtab=true');
}
}
else {
//クエリ文字列が含まれている場合は削除
if (href.indexOf('newtab') > 0) {
$(this).prop('href', href.replace('?newtab=true', ''));
}
}
});
//IEのコントロール同時押し対策
$('.link-field a').mousedown(function (event) {
if (event.ctrlKey) {
//クエリ文字列が含まれていない場合は付与
var href = $(this).prop('href').toLowerCase();
if (href.indexOf('newtab') <= 0) {
$(this).prop('href', href + '?newtab=true');
}
}
});
//右クリックメニューから新しいタブやウィンドウを開く場合のフラグ付け
$('.link-field a').on('contextmenu', function (e) {
var href = $(this).prop('href').toLowerCase();
//クエリ文字列が含まれていない場合は付与
if (href.indexOf('newtab') <= 0) {
$(this).prop('href', href + '?newtab=true');
}
});
});
※名前とタイトルが入力されていないコメントでは他のコメントとの区別ができません。
入力されていないコメントには返信しませんのであらかじめご了承くださいませ。