質問するログイン新規登録

質問編集履歴

3

追記

2019/01/23 01:52

投稿

tryCSharp
tryCSharp

スコア30

title CHANGED
File without changes
body CHANGED
@@ -106,4 +106,104 @@
106
106
  OS:Windows7
107
107
  .NET:4.0
108
108
  IIS:10.0 Express
109
- Visual Studio:2017 Community
109
+ Visual Studio:2017 Community
110
+
111
+ ### SurferOnWww様のご回答を受けてのソース
112
+ a.aspx
113
+ ```aspx
114
+ <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="a.aspx.cs" Inherits="TransferTest.a" %>
115
+
116
+ <!DOCTYPE html>
117
+
118
+ <html xmlns="http://www.w3.org/1999/xhtml">
119
+ <head runat="server">
120
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
121
+ <title></title>
122
+ </head>
123
+ <body>
124
+ <form id="form1" runat="server">
125
+ <div>
126
+ <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
127
+ <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
128
+ </div>
129
+ </form>
130
+ </body>
131
+ </html>
132
+ ```
133
+
134
+ a.aspx.cs
135
+ ```C#
136
+ using System;
137
+ using System.Collections.Generic;
138
+ using System.Linq;
139
+ using System.Web;
140
+ using System.Web.UI;
141
+ using System.Web.UI.WebControls;
142
+
143
+ namespace TransferTest
144
+ {
145
+ public partial class a : System.Web.UI.Page
146
+ {
147
+ protected void Page_Load(object sender, EventArgs e)
148
+ {
149
+
150
+ }
151
+
152
+ protected void Button1_Click(object sender, EventArgs e)
153
+ {
154
+ Session["id"] = TextBox1.Text;
155
+ // SerferOnWww様のご回答ではここで Session["A.aspx.SpecialKeyName"] にするということでしょうか?
156
+ Response.Redirect("b.aspx");
157
+ }
158
+ }
159
+ }
160
+ ```
161
+
162
+ b.aspx
163
+ ```aspx
164
+ <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="b.aspx.cs" Inherits="TransferTest.b" %>
165
+
166
+ <!DOCTYPE html>
167
+
168
+ <html xmlns="http://www.w3.org/1999/xhtml">
169
+ <head runat="server">
170
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
171
+ <title></title>
172
+ </head>
173
+ <body>
174
+ <form id="form1" runat="server">
175
+ <div>
176
+ <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
177
+ </div>
178
+ </form>
179
+ </body>
180
+ </html>
181
+ ```
182
+
183
+ b.aspx.cs
184
+ ```C#
185
+ using System;
186
+ using System.Collections.Generic;
187
+ using System.Linq;
188
+ using System.Web;
189
+ using System.Web.UI;
190
+ using System.Web.UI.WebControls;
191
+
192
+ namespace TransferTest
193
+ {
194
+ public partial class b : System.Web.UI.Page
195
+ {
196
+ string strId;
197
+
198
+ protected void Page_Load(object sender, EventArgs e)
199
+ {
200
+ if (!IsPostBack)
201
+ {
202
+ strId = Session["id"].ToString(); // ←ここで別タブのSession["id"]が上書きされてしまうのでは、と考えました。
203
+ Session["id"].Remove();
204
+ Label1.Text = strId;
205
+ }
206
+ }
207
+ }
208
+ }
209
+ ```

2

2019/01/23 01:52

投稿

tryCSharp
tryCSharp

スコア30

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  ### 前提・実現したいこと
2
- Page1でButtonを押した時、HiddenFieldの値を設定してPage2へPOSTしたいのですが、Buttton1_Click()内でHiddenField1に値を設定後、Server.Transfer()をすると値が設定できない上にURLがPage1のままなので都合が悪く(ユーザーにブックマークされたくない)、Response.Redirect()だとGETしか出来ないようなので使用を断念しています。
2
+ Page1でButtonを押した時、HiddenFieldの値を設定してPage2へPOSTしたいのですが、Buttton1_Click()内でHiddenFieldに値を設定後、Server.Transfer()をすると値が設定できない上にURLがPage1のままなので都合が悪く(ユーザーにブックマークされたくない)、Response.Redirect()だとGETしか出来ないようなので使用を断念しています。
3
3
  ButtonのPostBackUrlを使用するとHiddenFieldの値を設定するタイミングが分からず・・・。
4
4
 
5
5
  実現できなければ設計は変えようと思っていますがダメ元で質問させていただきました。

1

2019/01/22 15:21

投稿

tryCSharp
tryCSharp

スコア30

title CHANGED
File without changes
body CHANGED
@@ -103,7 +103,7 @@
103
103
  ```
104
104
 
105
105
  ### 補足情報(FW/ツールのバージョンなど)
106
- クライアントOS:Windows7
106
+ OS:Windows7
107
107
  .NET:4.0
108
- クライアントIIS:10.0 Express
108
+ IIS:10.0 Express
109
109
  Visual Studio:2017 Community