開発環境
「OS」Windows 10
「Visual Studio Community 2019」Ver16.9.4
「.NET Framework」Ver4.8
「jquery」Ver3.4.1
ラジオボタンリストから選択されたものをラベル表示する処理なのですが、
親ファイル(index.aspx)からデバック実行してもイベントが実行されず、エラーも表示されません。
子ファイル(Child_screen.aspx)からデバック実行するとイベントは実行されます。
尚イベント処理は子ファイルに記載しております。
親ファイルから実行してもイベント処理を動かしたいのですがどのようにすれば処理は実行されますでしょうか?
ソースは下記のとおりです。
◆index.aspx(親ファイル)
index.aspx
1<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="sample_quention.index" %> 2 3<!DOCTYPE html> 4 5<html xmlns="http://www.w3.org/1999/xhtml"> 6<head runat="server"> 7<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 8 <script src="../js/jquery-3.4.1.min.js"></script> 9 <script> 10 $(function () { 11 $("#child").load("Child_screen.aspx"); 12 }); 13 </script> 14</head> 15<body> 16 <form id="form1" runat="server"> 17 <div> 18 <p>親ページ</p> 19 </div> 20 <%-- ここから子画面読み込みファイル --%> 21 <div id="child"></div> 22 </form> 23</body> 24</html>
◆Child_screen.aspx(子ファイル)
Child_screen.aspx
1<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Child_screen.aspx.cs" Inherits="sample_quention.Child_screen" %> 2 3<!DOCTYPE html> 4 5<html xmlns="http://www.w3.org/1999/xhtml"> 6<head runat="server"> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 8 <title></title> 9</head> 10<body> 11 <form id="form1" runat="server"> 12 <div> 13 <p>子画面</p> 14 </div> 15 <asp:RadioButtonList ID="RadioList" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" OnSelectedIndexChanged="RadioList_SelectedIndexChanged"> 16 <asp:ListItem Text="Item 1" Value="Item 1" Selected="True"></asp:ListItem> 17 <asp:ListItem Text="Item 2" Value="Item 2"></asp:ListItem> 18 <asp:ListItem Text="Item 3" Value="Item 3"></asp:ListItem> 19 </asp:RadioButtonList> 20 21 <asp:Label ID="Label" runat="server"></asp:Label> 22 </form> 23</body> 24</html> 25
◆ Child_screen.aspx.cs(子ファイルイベント)
Child_screen.aspx.cs
1using System; 2using System.Collections.Generic; 3using System.Linq; 4using System.Web; 5using System.Web.UI; 6using System.Web.UI.WebControls; 7 8namespace sample_quention 9{ 10 public partial class Child_screen : System.Web.UI.Page 11 { 12 protected void Page_Load(object sender, EventArgs e) 13 { 14 15 } 16 17 protected void RadioList_SelectedIndexChanged(object sender, EventArgs e) 18 { 19 Label.Text = $"[{RadioList.SelectedValue}]が選択されました。"; 20 } 21 } 22}
またこの場合どのように検索したら解決方法に導けるのでしょうか
つたない説明で申し訳ありませんがご教授よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー