protected void Page_Load(object sender, EventArgs e) { System.Collections.IList visibleTables = ASP.global_asax.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages."); } Menu1.DataSource = visibleTables; Menu1.DataBind(); con.Open(); String query = "SELECT * FROM [dbo].[User] WHERE Email = @email"; SqlCommand com = new SqlCommand(query, con); SqlParameter CheckEmail = new SqlParameter("@email", Session["LoginEmail"]); com.Parameters.Add(CheckEmail); SqlDataReader retrieve = com.ExecuteReader(); if (retrieve.Read()) { Name = retrieve["FirstName"].ToString(); character = retrieve["Character"].ToString(); } (this.Master).nameValue = Name; (this.Master).CharValue = character; }
protected void Page_Load(object sender, EventArgs e) { if (Session["isLoginIn"] == "True") { } else { string id = Request.Params["userId"]; string pwd = Request.Params["pwd"]; if (pwd == "123@fabnfresh" && id == "fabnfresh") { Session["isLoginIn"] = "True"; } else { Response.Redirect("login.html"); } } System.Collections.IList visibleTables = ASP.global_asax.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages."); } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //SetMenuDataSource(eMenuToLoad); dsMenu.SiteMapProvider = "SecureSiteMap"; Menu1.Orientation = _orientation; Menu1.DataSource = dsMenu; dsMenu.ShowStartingNode = false; Menu1.DataBind(); }
public void DataBindMenu() { if (_dataSet != null) { Menu1.DataSource = _dataSet; Menu1.DataBind(); _dataBound = true; } }
protected void Page_Load(object sender, EventArgs e) { System.Collections.IList visibleTables = ASP.global_asax.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("No hay tablas accesibles. Asegúrese de que hay al menos un modelo de datos registrado en Global.asax y de que está habilitada la técnica scaffolding, o bien implemente páginas personalizadas."); } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { System.Collections.IList visibleTables = Global.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("沒有可存取的資料表。至少要在 Global.asax 中註冊一個資料模型,而且要啟用 Scaffolding 或實作自訂頁面。"); } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { System.Collections.IList visibleTables = MetaModel.Default.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("没有可访问的表。请确保至少在 Global.asax 中注册了一个数据模型并启用了支架,或者实现自定义页。"); } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { System.Collections.IList visibleTables = Global.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages."); } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { System.Collections.IList visibleTables = Global.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("Il n'y a aucune table accessible. Assurez-vous qu'au moins un modèle de données est inscrit dans Global.asax et que la génération de modèles automatique est activée, ou implémentez des pages personnalisées."); } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { System.Collections.IList visibleTables = Global.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("Нет ни одной доступной таблицы. Убедитесь, что по крайней мере одна модель данных зарегистрирована в Global.asax, а технология формирования шаблонов включена, либо реализуйте настраиваемые страницы."); } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
protected void RblDataSource_SelectedIndexChanged(object sender, EventArgs e) { string datasource = RblDataSource.SelectedValue; if (datasource == "XmlDataSource") { Menu1.DataSourceID = "XmlDataSource1"; } else { Menu1.DataSourceID = "SiteMapDataSource1"; } Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["name"] == null) { Response.Redirect("LoginDefault.aspx"); } else { if (!IsPostBack == true) { title.Text = "VYSHNAVI DAIRY WELCOMES YOU-" + Session["name"].ToString(); roless = Convert.ToInt32(Session["Role"]); if (roless == 9) { strUserRole = "Specialadmin"; } if (roless == 7) { strUserRole = "Superadmin"; } if (roless == 6) { strUserRole = "adminmanager"; } if (roless == 5) { strUserRole = "manager"; } if (roless == 4) { strUserRole = "Account"; } if (roless == 3) { strUserRole = "finance"; } if (roless == 2) { strUserRole = "user"; } if (roless == 1) { strUserRole = "Enduser"; } Menu1.DataSource = GetDataSource(strUserRole, Server.MapPath("~")); Menu1.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { System.Collections.IList visibleTables = MetaModel.Default.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages."); } Menu1.DataSource = visibleTables; Menu1.DataBind(); if (!Page.IsPostBack) { BindYearsDropDown(); BindSalesChart(DateTime.Now.Year); BindProductSalesChart(DateTime.Now.Year); BindLastSalesRepeater(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["token"] == null || (string)Session["token"] == "") { Session["refUrl"] = "~/Default.aspx"; Response.Redirect("~/Login.aspx"); return; } System.Collections.IList visibleTables = Global.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages."); } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { // if we haven't picked an FST version, we get the one from the config file, match it with the one in the database, set it on match, error on mismatch if (Session["FST_VERSION"] == null) { try { string appConfigVersion = ConfigurationManager.AppSettings.Get("FST_VERSION"); string databaseVersion = string.Empty; try { FST.Common.Database db = new FST.Common.Database(); databaseVersion = db.getVersion(); } catch (Exception ex) { Response.Write("Database conenction failed or internal application permissions were insufficient. Please notify the person responsible for this application."); Response.End(); return; } // we have a version mismatch, so print an error if (appConfigVersion != databaseVersion) { Response.Write("Current database version and application version do not match. This may be a configuration or deployment issue. Please notify the person responsible for this application."); Response.End(); return; } Session["FST_VERSION"] = FST_VERSION = appConfigVersion; } catch { } } else { FST_VERSION = Convert.ToString(Session["FST_VERSION"]); } try { // generate the proper path to the root URL. this actually comes out different on PWS vs IIS, so be careful about changing this. ImagePath = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath; ImagePath += (ImagePath.LastIndexOf('/') == ImagePath.Length - 1 ? string.Empty : "/"); if (!Page.IsPostBack) { // Show User Name if (Page.User.Identity.Name.ToString(CultureInfo.CurrentCulture) != null) { lblWellcome.Visible = lblUserName.Visible = true; lblUserName.Text = Page.User.Identity.Name.ToString(CultureInfo.CurrentCulture); } else { lblWellcome.Visible = lblUserName.Visible = false; } #region Set Menu roles from session variables bool blCheckUserInAdminRole = Roles.IsUserInRole("Admin"); if (blCheckUserInAdminRole) { Menu1.UserRoles.Add("ADMIN"); Menu1.UserRoles.Add("STANDARDS"); Menu1.UserRoles.Add("EDIT LAB KITS"); Menu1.UserRoles.Add("EDIT DEGRADED DROPOUT"); Menu1.UserRoles.Add("EDIT DROPIN"); Menu1.UserRoles.Add("EDIT FREQUENCY"); Menu1.UserRoles.Add("EDIT LAB TYPES"); Menu1.UserRoles.Add("EDIT POPULATION"); Menu1.UserRoles.Add("CREATE USER"); Menu1.UserRoles.Add("MANAGE USERS"); Menu1.UserRoles.Add("VIEW DROPOUT RATES"); Menu1.UserRoles.Add("VIEW SUBMITTED JOBS STATUS"); Menu1.UserRoles.Add("MANAGE SCENARIOS"); } #endregion #region Bind XML Data in Menu Control if (Menu1.DataSource == null) { // if we're in the root directory, use the root map. if we're up one, map accordingly. if (Server.MapPath("~").ToString() == Server.MapPath(".").ToString()) { Menu1.DataSource = Server.MapPath("~/XmlMenu.xml"); } else { Menu1.DataSource = Server.MapPath("~/XmlMenuOneUp.xml"); } Menu1.DataBind(); } #endregion } } catch (Exception ex) { #region redirect to Login Page Response.Redirect("login.aspx"); #endregion } #region CLEAR CACHE Response.Cache.SetNoStore(); Response.AddHeader("Cache-control", "no-store, must-revalidate, private,no-cache"); Response.AddHeader("Pragma", "no-cache"); Response.AddHeader("Expires", "0"); #endregion }
public void PopulateMenu(String UserName) { try { //UserName //http://www.codemyne.net/articles/Dynamic-Menu-using-Database-in-aspdotnet.aspx?visitid=25&type=2 Menu1.Items.Clear(); DataSet ds = new DataSet(); #region SQL Connection if (Connection.GetDBMode() == "Stage") { sqlStr = Connection.GetConnectionString("PS_Stage", ""); // PS_Production | PS_Stage } using (SqlConnection con = new SqlConnection(sqlStr)) { using (SqlCommand cmd = new SqlCommand("", con)) { if (con.State == ConnectionState.Closed) { con.Open(); } cmd.CommandTimeout = 600; cmd.CommandText = "[dbo].[user_menu_get_list]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Clear(); #region SQL Parameters cmd.Parameters.Add(new SqlParameter("@Source", "Web")); cmd.Parameters.Add(new SqlParameter("@SP_UserName", UserName)); cmd.Parameters.Add(new SqlParameter("@SP_ModuleID", 3)); // Donation ARC Portal #endregion SQL Parameters #region SQL Processing SqlDataAdapter ad = new SqlDataAdapter(cmd); ad.Fill(ds, "Menu"); #endregion SQL Processing } } #endregion SQL Connection ds.DataSetName = "Menus"; ds.Tables[0].TableName = "Menu"; DataRelation relation = new DataRelation("Parentchild", ds.Tables["Menu"].Columns["MenuID"], ds.Tables["Menu"].Columns["ParentId"], true); relation.Nested = true; ds.Relations.Add(relation); XmlDataSource xmlDataSource = new XmlDataSource(); xmlDataSource.ID = "XmlSource1"; xmlDataSource.EnableCaching = false; xmlDataSource.Data = ds.GetXml(); //Reformat the xmldatasource from the dataset to fit menu into xml format xmlDataSource.TransformFile = Server.MapPath("~/Menu.xslt"); //assigning the path to start read all MenuItem under MenuItems xmlDataSource.XPath = "MenuItems/MenuItem"; //Finally, bind the source to the Menu1 control Menu1.DataSource = xmlDataSource; Menu1.DataBind(); } catch (Exception ex) { //Error_Save(ex, "Error: Loading Menu"); } }
private void AppMenu_EnableMenuFunctionsForUser() { // ------------------------------------------------------------------------------------------- // operaciones necesarias para autorizar al usaurio las diferentes opciones del menú String[] sRolesForUser; sRolesForUser = Roles.GetRolesForUser(User.Identity.Name); // si el usuario no tiene roles, continuamos if (sRolesForUser.Count() == 0) { return; } if (sRolesForUser.ToList().Contains("Administradores")) { // si el usuario es administrador, continuamos sin procesar roles return; } dbGeneralDataContext dbGenerales = new dbGeneralDataContext(); List <String> MenuFunctionNames_List = new List <String>(); for (Int16 i = 0; i < sRolesForUser.Count(); i++) { // agregamos a una lista las opciones del menú definidas para los roles en los cuales // participa el usuario var query = from q in dbGenerales.Roles_FuncionesAplicacions where q.RoleName == sRolesForUser[i] select new { q.FunctionName }; foreach (var MenuFunctionName_obj in query) { MenuFunctionNames_List.Add(MenuFunctionName_obj.FunctionName); } } dbGenerales = null; if (MenuFunctionNames_List.Count() == 0) { // el usuario pertenece a roles pero que no tienen funciones (???!!) return; } // con las funciones permitidas al usuario en una lista, recorremos el menú y activamos solo // esas opciones Menu1.DataBind(); // primero desabilitamos todas las opciones; más abajo, habilitamos solo las que correspondan foreach (MenuItem MyMenuItem in Menu1.Items) { DesabilitarMenuItem(MyMenuItem); } // recorremos el menú para mostrar solo las opciones permitidas el (los) role al cual // corresponde el usuario foreach (MenuItem MyMenuItem in Menu1.Items) { ProcessMenuItem(MyMenuItem, MenuFunctionNames_List); } }
protected void Page_Load(object sender, EventArgs e) { object usertime = Session["user"]; object currentuser = Session["currentuser"]; object usertype = Session["usertype"]; #region HANDLE USER if (usertime == null || usertype == null || currentuser == null) { Session.Add("user", DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00")); Response.Redirect("~/login.aspx"); return; } if ((string)currentuser == "Unknown") { Session["usertype"] = null; Session["currentuser"] = null; Response.Redirect("~/login.aspx"); } DateTime now = DateTime.UtcNow.AddDays(-1); if (!DateTime.TryParseExact((string)usertime, "yyyy-MM-dd HH:mm:00", null, System.Globalization.DateTimeStyles.AssumeUniversal, out now)) { Session["user"] = DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00"); Response.Redirect("~/login.aspx"); return; } if (now.AddMinutes(UtilsConfig.SessionTimeAsMinutes) < DateTime.UtcNow) { Session["user"] = DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00"); Response.Redirect("~/login.aspx"); return; } #endregion enumUserType currentusertype = (enumUserType)Session["usertype"]; //System.Collections.IList visibleTables = ASP.global_asax.DefaultModel.VisibleTables; List <MetaTable> visibleTables = ASP.global_asax.DefaultModel.VisibleTables; if (visibleTables.Count == 0) { throw new InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages."); } switch (currentusertype) { case enumUserType.Developers: break; case enumUserType.Admins: if (UtilsConfig.AdminTables.Count > 0 && UtilsConfig.AdminTables[0] != string.Empty) { visibleTables = (from vt in visibleTables where UtilsConfig.AdminTables.Contains(((MetaTable)vt).Name.ToLower()) select vt).ToList(); } break; case enumUserType.Users: if (UtilsConfig.UserTables.Count > 0 && UtilsConfig.UserTables[0] != string.Empty) { visibleTables = (from vt in visibleTables where UtilsConfig.UserTables.Contains(((MetaTable)vt).Name.ToLower()) select vt).ToList(); } break; default: { Session["user"] = DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00"); Response.Redirect("~/login.aspx"); return; } break; } Menu1.DataSource = visibleTables; Menu1.DataBind(); }
private void CreateMenuControl() { Menu1.DataSource = GetSiteMapDataSource(); Menu1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Menu1.DataSource = RouteConfig.VisibleTables; Menu1.DataBind(); }