Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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
Posted

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

--Pankaj
 
Share this answer
 
Comments
sharmarun 7-Mar-11 0:53am    
there is no click event in hyperlink properties

m using asp.net with c3
pankajupadhyay29 7-Mar-11 0:54am    
did you read complete post??
use Linkbutton Not Hyperlink then you get click event and same look and feel as hyperlink.
sharmarun 7-Mar-11 0:57am    
kso means with hyperlink it is not possible yah?
pankajupadhyay29 7-Mar-11 1:00am    
ya but with LinkButton you can achive the same.

hope this will help.
ProgrammerAt 7-Mar-11 1:12am    
where you want to save the data after click event? in a database?
XML
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;
           }
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900