即使在单击下一页重定向按钮后仍保留复选框 [英] Retain checkbox checked even after next page redirect button clicked

查看:90
本文介绍了即使在单击下一页重定向按钮后仍保留复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

保留复选框



我尝试了什么:

<即使在单击下一页重定向按钮

retain checkbox checked even after next page redirect button clicked

What I have tried:

retain checkbox checked even after next page redirect button clicked

推荐答案

HI,


$ b后,也检查了
保留复选框$ b您可以在会话中保存复选框状态。在下一页,您可以使用此值。



使用会话的示例:



你的第1页



You can save the checkbox state in a session. On the next page you can use this value.

An example using session:

YOUR PAGE 1
<body>
    <form id="form1" runat="server">
        <asp:CheckBox ID="my_check" runat="server" Text="My Check 1" />
        <br />
        <asp:Button ID="btn" runat="server" Text="Next Page" OnClick="btn_Click" />
    
    </form>
</body>




protected void btn_Click(object sender, EventArgs e)
{
   HttpContext.Current.Session.Add("my_check", this.my_check.Checked);
   Response.Redirect("page2.aspx");
}





你的第2页



YOUR PAGE 2

<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="my_check_2" runat="server" Text="My Check 2" />
    </div>
    </form>
</body>




protected void Page_Load(object sender, EventArgs e)
{
   if (!IsPostBack)
   { 
      this.my_check_2.Checked = (bool)HttpContext.Current.Session["my_check"];
   }
}


这篇关于即使在单击下一页重定向按钮后仍保留复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆