如何在会话中获取选中的复选框值 [英] how to get selected checkbox value in session

查看:92
本文介绍了如何在会话中获取选中的复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我的代码





 <   asp:RadioButton     ID   =  RadioButton2    GroupName   = 大小    runat   =   server   文字 < span class =code-keyword> =     /  >  
< asp:RadioButton ID = RadioButton3 GroupName = 尺寸 runat = server 文字 = / >
< asp:RadioButton ID = RadioButton4 GroupName = 大小 runat = server 文本 = XL / >
< asp:RadioButton ID = RadioButton5 GroupName = 大小 runat = 服务器 正文 = XXL / >
< asp:RadioButton ID = RadioButton6 GroupName = 大小 runat = server 文本 = XS / >





当以上任何一个单选按钮是检查比它的值存储在会话中所以我该怎么办

解决方案

试试这个:



<前一个=c#> 如果(RadioButton2.Checked == true
会话[ size] = ;
else if (RadioButton3.Checked == true
会话[ size] = Large;
else if (RadioButton4.Checked == true
会话[ size] = XL;
else if (RadioButton5.Checked == true
会话[ size] = XXL;
else if (RadioButton6.Checked == true
会话[ size] = XS;





当你想获得会话值时使用



Session [size]。ToString();


Hello

My Code


<asp:RadioButton ID="RadioButton2" GroupName="Size" runat="server" Text="Medium" />
             <asp:RadioButton ID="RadioButton3" GroupName="Size" runat="server" Text="Large" />
             <asp:RadioButton ID="RadioButton4" GroupName="Size" runat="server" Text="XL" />
             <asp:RadioButton ID="RadioButton5" GroupName="Size" runat="server" Text="XXL" />
             <asp:RadioButton ID="RadioButton6" GroupName="Size" runat="server" Text="XS" />



when any of above radio button is checked than it''s value is stored in session so how can i do it

解决方案

try this :

if (RadioButton2.Checked == true)
            Session["size"] = "Medium";
        else if (RadioButton3.Checked == true)
            Session["size"] = "Large";
        else if (RadioButton4.Checked == true)
            Session["size"] = "XL";
        else if (RadioButton5.Checked == true)
            Session["size"] = "XXL";
        else if (RadioButton6.Checked == true)
            Session["size"] = "XS";



and when you want to get the session value use

Session["size"].ToString();


这篇关于如何在会话中获取选中的复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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