如何保存点击超链接 [英] how to save on click on a hyperlink

查看:154
本文介绍了如何保存点击超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有一个超链接点击超链接重定向到下一页问题是我必须保存我的上一页的数据才能进入下一页

i have a hyperlink on page on click on hyperlink to redirect to next page the problem is that i have to save my previous page''s data before going to next page

推荐答案

使用链接按钮并在点击事件中保存数据然后使用Response.Redirect(您的位置)



--Pankaj
use a Link button and save data on the click event then Use Response.Redirect("Your Location")

--Pankaj


protected void btnLogin_Click(object sender, EventArgs e)
       {
           #region Remember Me
           if (check.Checked == true)
           {
               Response.Cookies["UName"].Value = txtUserName.Text;
               Response.Cookies["PWD"].Value = txtPassword.Text;
               Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(2);
               Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(2);
           }
           else
           {
               Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(-1);
               Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(-1);
           }
           #endregion

           this.userManager = new UserManager();
           this.roleManager = new RoleManager();
           this.moduleManager = new ModuleManager();
           List<Module> moduleListObject;
           List<PMSBL.Entity.User> userListObj;
           PMSBL.Entity.Role roleObj;
           Module moduleObj;
           List<KeyValuePair<string, object>> list;
           try
           {
               string encstr = EncryptDecryptManager.Encrypt(txtPassword.Text.Trim(), true);
               userListObj = userManager.UserGetByIdPassword(txtUserName.Text.Trim(), encstr);
               PMSBL.Entity.User userObj = null;

               if (userListObj != null)
               {
                   if (userListObj.Count == 1)
                   {
                       Session[SessionKeys.UserSessionObject] = new SessionObject();
                       SessionObject.Sess(Session).SiteUser = userListObj.FirstOrDefault();

                       //get role by roleid
                       list = new List<KeyValuePair<string, object>>();
                       list.Add(new KeyValuePair<string, object>("ID", SessionObject.Sess(Session).SiteUser.RoleId));
                       roleObj = roleManager.RolesGet(list).FirstOrDefault();
                       FormsAuthentication.SetAuthCookie(SessionObject.Sess(Session).SiteUser.Email, false);
                       //SecurityManager.AddCookie(SessionObject.Sess(Session).SiteUser.Email, SessionObject.Sess(Session).SiteUser.RoleName);
                       //get all assigned module to this role
                       list = new List<KeyValuePair<string, object>>();
                       list.Add(new KeyValuePair<string, object>("RoleId", SessionObject.Sess(Session).SiteUser.RoleId));
                       moduleListObject = moduleManager.ModuleGet(list);
                       if (moduleListObject != null)
                           SessionObject.Sess(Session).UserModules = moduleListObject;

                       //get landing page by roleobj
                       if (roleObj != null)
                       {
                           string removeAbbreviation = roleObj.LandingPage;
                           if (removeAbbreviation.Contains('('))
                               removeAbbreviation = removeAbbreviation.Substring(0, removeAbbreviation.IndexOf('(') - 1);

                           list = new List<KeyValuePair<string, object>>();
                           list.Add(new KeyValuePair<string, object>("ModuleName", removeAbbreviation.Trim()));
                           list.Add(new KeyValuePair<string, object>("RoleId", roleObj.ID));

                           List<Module> moduleList = moduleManager.ModuleGet(list);
                           if (moduleList != null)
                           {
                               moduleObj = moduleList.FirstOrDefault();
                               if (moduleObj != null)
                               {
                                   if (moduleObj.ModuleUrl != "")
                                   {
                                       if (Common.IsRouting)
                                           Response.Redirect("/" + moduleObj.RouteUrl);
                                       else
                                           Response.Redirect(moduleObj.ModuleUrl);
                                   }
                                   else
                                       Response.Redirect("~/Default.aspx");
                               }
                           }
                           else
                               Response.Redirect("~/Default.aspx");
                       }
                       else
                           Response.Redirect("~/Default.aspx");
                   }
                   else
                       Response.Redirect("~/AccessDenied.aspx");
               }
               else
               {
                   Response.Redirect("~/AccessDenied.aspx");
               }
           }
           catch (Exception ex)
           {

               throw;
           }
       }


这篇关于如何保存点击超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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