在网页中,有大量不同的控件,例如(文本框,单选按钮,复选框,下拉列表) [英] In a web page there are huge number of different controls like(textbox,radiobutton,checkbox,dropdown)

查看:73
本文介绍了在网页中,有大量不同的控件,例如(文本框,单选按钮,复选框,下拉列表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,民谣



在网页中,有大量不同的控件,例如(文本框,单选按钮,复选框,下拉列表)近100个控件.


这是一个填写三个级别的注册表格,即填写1级之后的内容.
必须将控件中的字段值保存在会话中才能做到这一点

我在下面提供示例代码,请检查一下.......



ClearInputs(Page.Controls);//调用上面的函数

Hi folk''s



In a web page there are huge number of different controls like(textbox,radiobutton,checkbox,dropdown) nearly 100 controls.


It is a registration form three levels of registration ,that is after filling level-1
what ever the field values in a controls must be saved in a session to do that

I am giving sample code below please check it out .......



ClearInputs(Page.Controls);//calling the function which is above

void ClearInputs(ControlCollection cs)//to get the text in a controls and store in a session variables
    {
        foreach (Control c in cs)
        {
            if (c is TextBox)
            {
                Session["New"] = ((TextBox)c).Text;
                lbl_savesubmit1.Text += Session["New"];
            }
        }
    }

推荐答案

void ClearInputs(ControlCollection cs)//to get the text in a controls and store in a session variables
    {
        foreach (Control c in cs)
        {
            if (c is TextBox)
            {
                Session["New"+c.ID] = ((TextBox)c).Text;
                lbl_savesubmit1.Text += Session["New"+c.ID];
            }
        }
    }



您可以在foreach中的每个循环上覆盖变量会话.那没有道理.

希望它能以任何方式提供帮助.



You override the variable session on each loop inside your foreach. That make no sense.

Hope it helps in any way.


这篇关于在网页中,有大量不同的控件,例如(文本框,单选按钮,复选框,下拉列表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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