微信公众账户开发 之 两个页面同时提交数据

1.两个页面(第一个页面,第二个页面)

第一个页面录入完成点击下一步,跳转到第二个页面,数据录入完毕之后点击提交,将数据添加到数据库中:
private Hashtable  SaveInfo(Model model)
        {
            Model.test test1 = new Model.test();


            test1.phone = model.UserMobile;         //手机号码
            test1.name = model.UserName;            //姓名
            test1.cjiname = model.Company;          //公司名称
            test1.job = model.UserPosition;         //职位
            test1.email = model.UserEmail;          //邮箱


            //实例化Hashtable,将第一页的数据存储到Hashtable中。
            Hashtable ht = null;
            if (Session["step1"] == null && Session["step1"] != "")
                ht = new Hashtable(); //实例化一个Hashtable。   
            else
                ht = (Hashtable)Session["step1"];
            string[] filed = { "UserName", "company", "UserPosition", "UserEmail", "Phone" };
            string[] filedValue = { test1.name, test1.cjiname, test1.job, test1.email, test1.phone};
            for (int i = 0; i < filed.Length; i++)
            {
                string key = filed[i].ToString();
                string value = filedValue[i].ToString();
                if (ht.Contains(key))
                {
                    ht.Remove(key);
                    ht.Add(key, filedValue[i].ToString());
                }
                else
                {
                    ht.Add(key, value);
                }
            }


            Session["step1"] = ht;
            return ht;
        }

2.将Session中存储的Hashtable数据根据key循环遍历得到value,将遍历得到的数据赋给当前页面的实体类,然后提交即可。


private void SaveAnswerPageInfo(Model model)
        {

            Hashtable firstInfo = new Hashtable();
            firstInfo = (Hashtable)Session["step1"];
           
            string phonevalue = "";
            string UserNamevalue = "";
            string companyvalue = "";
            string UserPositionvalue = "";
            string UserEmailvalue = "";
            foreach (System.Collections.DictionaryEntry de in firstInfo)
            {
                if (de.Key.ToString() == "Phone")
                {
                    phonevalue = de.Value.ToString();//得到值
                    break;//退出foreach遍历
                }
            }
            foreach (System.Collections.DictionaryEntry de in firstInfo)
            {
                if (de.Key.ToString() == "UserName")
                {
                    UserNamevalue = de.Value.ToString();//得到值
                    break;//退出foreach遍历
                }
            }
            foreach (System.Collections.DictionaryEntry de in firstInfo)
            {
                if (de.Key.ToString() == "company")
                {
                    companyvalue = de.Value.ToString();//得到值
                    break;//退出foreach遍历
                }
            }
            foreach (System.Collections.DictionaryEntry de in firstInfo)
            {
                if (de.Key.ToString() == "UserPosition")
                {
                    UserPositionvalue = de.Value.ToString();//得到值
                    break;//退出foreach遍历
                }
            }
            foreach (System.Collections.DictionaryEntry de in firstInfo)
            {
                if (de.Key.ToString() == "UserEmail")
                {
                    UserEmailvalue = de.Value.ToString();//得到值
                    break;//退出foreach遍历
                }
            }
            ZHGLModel.phone = phonevalue;
            ZHGLModel.name = UserNamevalue;
            ZHGLModel.cjiname = companyvalue;
            ZHGLModel.job = UserPositionvalue;
            ZHGLModel.email = UserEmailvalue;
            
        }




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值