質問編集履歴
1
asp.netタグ追加とコード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,24 +32,25 @@
|
|
32
32
|
<script runat="server">
|
33
33
|
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
34
34
|
If Page.IsPostBack Then
|
35
|
+
|
36
|
+
Dim index As Integer = Integer.Parse(Request.Form("FocusIndex"))
|
37
|
+
|
35
|
-
Dim
|
38
|
+
Dim length As String = Request.Form("FocusLength")
|
36
39
|
Dim targetId As String = Request.Form("FocusItem")
|
37
40
|
Dim target As TextBox = DirectCast(FindControl(targetId), TextBox)
|
38
41
|
Dim inserttext As String = "ダミー"
|
39
42
|
|
40
|
-
If String.IsNullOrEmpty(focusindex) OrElse CInt(focusindex) >= target.Text.Length Then
|
41
|
-
target.Text &= inserttext
|
42
|
-
Else
|
43
|
-
Dim cursorPosition As Integer = CInt(focusindex)
|
44
|
-
|
43
|
+
target.Text = target.Text.Substring(0, index) + inserttext + target.Text.Substring(index - length)
|
45
|
-
|
44
|
+
|
45
|
+
|
46
|
+
|
46
47
|
End If
|
47
48
|
End Sub
|
48
49
|
</script>
|
49
50
|
|
50
51
|
<html>
|
51
52
|
<head>
|
52
|
-
<script src="https://code.jquery.com
|
53
|
+
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
|
53
54
|
<title></title>
|
54
55
|
</head>
|
55
56
|
<body>
|
@@ -71,7 +72,10 @@
|
|
71
72
|
<script>
|
72
73
|
$("textarea").on("focus click keyup", function (e) {
|
73
74
|
$("#FocusItem").val(e.target.id);
|
75
|
+
var index = e.target.selectionStart;
|
76
|
+
$("#FocusIndex").val(index);
|
74
|
-
$("#Focus
|
77
|
+
$("#FocusLength").val(e.target.selectionEnd - index);
|
78
|
+
console.log(e.target.selectionEnd);
|
75
79
|
});
|
76
80
|
</script>
|
77
81
|
</body>
|