标题if ( RadioButtonList1.SelectedItem.Value == myRead usetype.ToString())值相同可为什么判定为false

本文探讨了一位开发者在使用C#进行条件判断并尝试页面跳转时遇到的问题。尽管RadioButtonList1.SelectedItem.Value与myRead[usetype].ToString()两值相等,但Response.Redirect(student.aspx)无法正常工作。然而,当直接将字符串student用于比较时,跳转功能正常。文章详细描述了这一现象,并寻求解决方案。

标题if ( RadioButtonList1.SelectedItem.Value == myRead[“usetype”].ToString()

  { Response.Redirect("student.aspx"); }
  没有报错但是实现不了跳转,测试过两个值都是相等的
  RadioButtonList1.SelectedItem.Value获取到的值是student
  myRead["usetype"].ToString()这个获取到的值也是student
  可是就是实现不了Response.Redirect("student.aspx");这段话的功能
	但是当if ( RadioButtonList1.SelectedItem.Value==“student”)
                {
                    Response.Redirect("student.aspx");
                }
       它能自动跳转到student.aspx
       怎么解决呀
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } } protected void Button1_Click(object sender, EventArgs e) { string classInfo = TextBox2.Text.Trim(); string studentId = TextBox3.Text.Trim(); string name = TextBox1.Text.Trim(); // 验证姓名是否为空 if (string.IsNullOrEmpty(classInfo)) { Label1.Text = "请输入班级后再提交!"; return; } if (string.IsNullOrEmpty(studentId)) { Label1.Text = "请输入学号后再提交!"; return; } if (string.IsNullOrEmpty(name)) { Label1.Text = "请输入姓名后再提交!"; return; } int score = 0; string detail = ""; if (RadioButtonList4.SelectedValue == "A.asx") { score += 20; detail += "第一题回答正确! "; } else { detail += "第一题回答错误!正确答案:A.asx,您的答案:" + RadioButtonList4.SelectedValue + ""; } if (RadioButtonList2.SelectedValue == "B.动态网页开发技术") { score += 20; detail += "第二题回答正确! "; } else { detail += "第二题回答错误!正确答案:B.动态网页开发技术,您的答案:" + RadioButtonList2.SelectedValue + " "; } if (RadioButtonList3.SelectedValue == "D.分号") { score += 20; detail += "第三题回答正确! "; } else { detail += "第三题回答错误!正确答案:D.分号,您的答案:" + RadioButtonList3.SelectedValue + " "; } List<string> userSelectedTextsQ4 = new List<string>(); // 存储用户选中的选项(用于和正确答案的“”比对) List<string> userSelectedValuesQ4 = new List<string>(); bool isQ4correct = true; string correctQ4 = "A.Java,B.C++"; string userQ4 = ""; foreach (ListItem item1 in CheckBoxList2.Items) { if (item1.Selected) userQ4 += item1.Value + ","; if (item1.Selected != (correctQ4.Contains(item1.Value))) { isQ4correct = false; } } if (isQ4correct && userQ4.TrimEnd(',') == correctQ4) { score += 20; detail += "第四题回答正确! "; } else { detail += "第四题回答错误!正确答案:A.Java,B.C++,您的答案:" + userQ4.TrimEnd(',') + " "; } bool isQ5correct = true; string correctQ5 = "A.Botton,B.CheckBox,C.TextBox"; string userQ5 = ""; foreach (ListItem item1 in CheckBoxList2.Items) { if (item1.Selected) userQ5 += item1.Value + ","; if (item1.Selected != (correctQ5.Contains(item1.Value))) { isQ5correct = false; } } if (isQ5correct && userQ5.TrimEnd(',') == correctQ5) { score += 20; detail += "第五题回答正确! "; } else { detail += "第五题回答错误!正确答案:A.Botton,B.CheckBox,C.TextBox,您的答案:" + userQ5.TrimEnd(',') + " "; Label2.Text = "满分100分,您的分数是" + score + "分" + detail; } } }
最新发布
09-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值