回答編集履歴

3

追記

2018/06/06 01:26

投稿

退会済みユーザー
test CHANGED
@@ -177,3 +177,91 @@
177
177
 
178
178
 
179
179
  質問者さんは一体何を見て制御が飛ばないと言っているのですか?
180
+
181
+
182
+
183
+ **【2018/6/6 10:25 追記】**
184
+
185
+
186
+
187
+ 下の 2018/06/06 10:12 の私のコメントで「修正後のコードは回答欄に追記しておきます」と書きましたが、それを以下に書きます。.aspx.cs の方は質問者さんが質問に書いたコードそのままで問題ないはずです。
188
+
189
+
190
+
191
+ 詳しい原因は追究できてませんが、非同期ポストバック後の応答で ComboBox1, ComboBox2 の両方を再描画しないとダメということのようです。(質問者さんのコードでは ComboBox2 しか UpdatePanel に含まれてないので、非同期ポストバック後の応答で ComboBox1 とそれに付随するスクリプト他が再描画されない)
192
+
193
+
194
+
195
+ ```
196
+
197
+ <%@ Page Language="C#" AutoEventWireup="true"
198
+
199
+ CodeBehind="ComboBox.aspx.cs" Inherits="WebFormsAppNET4.ComboBox" %>
200
+
201
+
202
+
203
+ <!DOCTYPE html>
204
+
205
+
206
+
207
+ <html xmlns="http://www.w3.org/1999/xhtml">
208
+
209
+ <head runat="server">
210
+
211
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
212
+
213
+ <title></title>
214
+
215
+ <%--<asp:PlaceHolder runat="server">
216
+
217
+ <%: System.Web.Optimization.Styles.Render("~/Content/AjaxControlToolkit/Styles/Bundle") %>
218
+
219
+ </asp:PlaceHolder>--%>
220
+
221
+ </head>
222
+
223
+ <body>
224
+
225
+ <form id="form1" runat="server">
226
+
227
+ <asp:ScriptManager ID="ScriptManager1" runat="server">
228
+
229
+ <%--<Scripts>
230
+
231
+ <asp:ScriptReference Path="~/Scripts/AjaxControlToolkit/Bundle" />
232
+
233
+ </Scripts>--%>
234
+
235
+ </asp:ScriptManager>
236
+
237
+
238
+
239
+ <asp:UpdatePanel ID="UpdatePanel1" runat="server">
240
+
241
+ <ContentTemplate>
242
+
243
+ <ajaxToolkit:ComboBox ID="ComboBox1" runat="server"
244
+
245
+ AutoPostBack="True"
246
+
247
+ OnSelectedIndexChanged="ComboBox1_SelectedIndexChanged">
248
+
249
+ </ajaxToolkit:ComboBox>
250
+
251
+
252
+
253
+ <ajaxToolkit:ComboBox ID="ComboBox2" runat="server">
254
+
255
+ </ajaxToolkit:ComboBox>
256
+
257
+ </ContentTemplate>
258
+
259
+ </asp:UpdatePanel>
260
+
261
+ </form>
262
+
263
+ </body>
264
+
265
+ </html>
266
+
267
+ ```

2

追伸追加

2018/06/06 01:26

投稿

退会済みユーザー
test CHANGED
@@ -15,3 +15,165 @@
15
15
 
16
16
 
17
17
  前のスレッドでも言いましたが、コードをどんどん削っていって、ホントに制御が飛んでないか調べてください。
18
+
19
+
20
+
21
+ **【追伸】**
22
+
23
+
24
+
25
+ 念のため以下のコードで検証してみましたが、ComboBox の選択を変更するたび間違いなく ComboBox1_SelectedIndexChanged メソッドに制御は飛びます。
26
+
27
+
28
+
29
+ .aspx のコメントアウトしたコードはスクリプト、CSS ファイルをバンドルするためのものですが、そこは関係ないです(コメントアウトしてもしなくても同じ)。
30
+
31
+
32
+
33
+ **.aspx.cs**
34
+
35
+
36
+
37
+ ```
38
+
39
+ using System;
40
+
41
+ using System.Collections.Generic;
42
+
43
+ using System.Linq;
44
+
45
+ using System.Web;
46
+
47
+ using System.Web.UI;
48
+
49
+ using System.Web.UI.WebControls;
50
+
51
+
52
+
53
+ namespace WebFormsAppNET4
54
+
55
+ {
56
+
57
+ public partial class ComboBox : System.Web.UI.Page
58
+
59
+ {
60
+
61
+ protected void Page_Load(object sender, EventArgs e)
62
+
63
+ {
64
+
65
+ if (!Page.IsPostBack)
66
+
67
+ {
68
+
69
+ ComboBox1.Items.Clear();
70
+
71
+ ListItem li = new ListItem("1", "1");
72
+
73
+ ComboBox1.Items.Add(li);
74
+
75
+ li = new ListItem("2", "2");
76
+
77
+ ComboBox1.Items.Add(li);
78
+
79
+ li = new ListItem("3", "3");
80
+
81
+ ComboBox1.Items.Add(li);
82
+
83
+ }
84
+
85
+
86
+
87
+ }
88
+
89
+
90
+
91
+ protected void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
92
+
93
+ {
94
+
95
+ int index = ComboBox1.SelectedIndex;
96
+
97
+ ListItem item = ComboBox1.SelectedItem;
98
+
99
+ string value= ComboBox1.SelectedValue;
100
+
101
+
102
+
103
+ Label1.Text = value;
104
+
105
+ }
106
+
107
+ }
108
+
109
+ }
110
+
111
+ ```
112
+
113
+ **.aspx**
114
+
115
+
116
+
117
+ ```
118
+
119
+ <%@ Page Language="C#" AutoEventWireup="true"
120
+
121
+ CodeBehind="ComboBox.aspx.cs" Inherits="WebFormsAppNET4.ComboBox" %>
122
+
123
+
124
+
125
+ <!DOCTYPE html>
126
+
127
+
128
+
129
+ <html xmlns="http://www.w3.org/1999/xhtml">
130
+
131
+ <head runat="server">
132
+
133
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
134
+
135
+ <title></title>
136
+
137
+ <%--<asp:PlaceHolder runat="server">
138
+
139
+ <%: System.Web.Optimization.Styles.Render("~/Content/AjaxControlToolkit/Styles/Bundle") %>
140
+
141
+ </asp:PlaceHolder>--%>
142
+
143
+ </head>
144
+
145
+ <body>
146
+
147
+ <form id="form1" runat="server">
148
+
149
+ <asp:ScriptManager ID="ScriptManager1" runat="server">
150
+
151
+ <%--<Scripts>
152
+
153
+ <asp:ScriptReference Path="~/Scripts/AjaxControlToolkit/Bundle" />
154
+
155
+ </Scripts>--%>
156
+
157
+ </asp:ScriptManager>
158
+
159
+ <ajaxToolkit:ComboBox ID="ComboBox1" runat="server" AutoPostBack="True"
160
+
161
+ OnSelectedIndexChanged="ComboBox1_SelectedIndexChanged">
162
+
163
+ </ajaxToolkit:ComboBox>
164
+
165
+
166
+
167
+ <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
168
+
169
+ </form>
170
+
171
+ </body>
172
+
173
+ </html>
174
+
175
+ ```
176
+
177
+
178
+
179
+ 質問者さんは一体何を見て制御が飛ばないと言っているのですか?

1

引用追加

2018/06/05 11:50

投稿

退会済みユーザー
test CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
7
 
8
8
 
9
+ > ComboBox1_SelectedIndexChangedへ初期表示の1度だけしか飛んでこず、その後はComboBox1の内容を変えてもComboBox1_SelectedIndexChangedへ飛んできません。
10
+
11
+
12
+
9
13
  多分また前のスレッドの制御が飛ばないという話と同様に調べ方の問題・勘違いだと思います。
10
14
 
11
15