我有一个asp.net webform
网页,其中有2个单选按钮,这些单选按钮选择的值存储在session
,并显示我的确认页面上。当用户点击提交按钮时,会发送一封包含所有详细信息的电子邮件(同样所有详细信息均以session
显示)。传递会话价值的另一个阶段价值
我获得选择的单选按钮,在我的电子邮件的价值的问题。我能看到的唯一选项是有两个相同的字段标签,其中一个是空的,另一个会显示会话中选定的值。
我尝试添加以下IF
到我的电子邮件正文中,但它从我的邮箱中删除所有的细节。
我想我可以在我的.cs
文件中使用的IF statement
来检查一个单选按钮是不是null
然后创建另一个session variable
。我无法弄清楚如何通过在IF
条件下的session
值来填充新的session
。
的HTML页面单选按钮背后
<div class="form-group">
<asp:Label ID="PrefContactLabel" class="col-sm-3 control-label" runat="server" Text="Preferred method of contact *" style="padding-top: 0px"></asp:Label>
<div class="col-sm-3">
<asp:Label runat="server" class="radio-inline" style="padding-top: 0px">
<asp:RadioButton runat="server" id="PhoneRadioButton" value="Phone" GroupName="prefcontact"/> Phone
</asp:Label>
<asp:Label runat="server" class="radio-inline" style="padding-top: 0px">
<asp:RadioButton runat="server" id="EmailRadioButton" value="Email" GroupName="prefcontact"/> Email
</asp:Label>
</div>
<div class="col-sm-offset-3 col-sm-9">
<asp:CustomValidator id="custPrefContact" runat="server" Display="Dynamic" ForeColor="Red" ErrorMessage="Please select a preferred method of contact." ClientValidationFunction="PrefContact_ClientValidate" OnServerValidate="PrefContact_ServerValidate" />
</div>
</div>
代码对于页面单选按钮在
protected void Step01SubmitButton_Click(object sender, EventArgs e)
{
Session["PhoneRadioButton"] = PhoneRadioButton.Checked ? "Phone" : "";
Session["EmailRadioButton"] = EmailRadioButton.Checked ? "Email" : "";
}
这是一个开局IF
声明,我增加了上面的代码
if (Session["PhoneRadioButton"].ToString() == "Phone" || Session["EmailRadioButton"].ToString() == "Email")
{
Session["PrefContactRadioButton"] = Step01HiddenPrefField.Text;
}
这是代码,打破我的确认页面上我的电子邮件行
Label4.Text + " " + Session["PhoneRadioButton"].ToString() == "Phone" ? Session["PhoneRadioButton"].ToString() : Session["EmailRadioButton"].ToString();
我想填充我的“会话[” PrefContactRadioButton“]”与“会话[” PhoneRadioButton“] /会话值[ “EmailRadioButton”]”。
“中断”的行似乎没有使用前面的代码中的任何Session变量。 – Magnus
@Magnus对不起,我把这条线注释掉了,并且改变了我的会话名称,但是我已经更新了打断它的那一行 – murday1983
它究竟打破了什么?你得到的错误是什么?我仍然不明白你的问题。 – Magnus