Web Forms :: Accessing User Identity From Master Page?
Jan 23, 2010
When I use a Master Page with a Content Page, in the Content Page script I find that User object is defined, with Identity and IsInRole properties. However, when I enter script on the Master Page itself User comes up as "not declared".
I am guessing that User is embedded in some namespace that is automatically imported to Content pages, but haven't been able to track it down.
I'm trying to access User.Identity from my master page so I can figure out which user is logged in, however I can't get it to work. If I import System.Security.Principal in my master page it makes no difference:
I have looked everywhere for how to do this and all I come up with is threads describing how to expose public properties. I have a USER CONTROL in my Master page. It is a search box with a text box and a dropdown for search type (last name, account number, etc) and a search button. When the user clicks the search button, I open a new page that displays the results. How do I pass the values from the USER CONTROL search fields to the new page? I would post code, but I have nothing to post yet since I don't know where to start. I have tried exposing the public property of the user control, but I don't know how to retrieve those values on the results page.
I've got a web site that has a master page and that master page (mpMaster that has a user control ucControl1) which has a sub user control (ucControl2), this user control has a property which accepts a value. Now, I have a page that uses the master page and on this page I have another user control (ucPageControl), I need to find a way of setting the value in ucControl2 from ucPageControl. Is this possible at all?
I have a textbox and a button, and I trying to give the user a search option in the master page. The onClick event of my button is fine, but the textbox.Text property is always empty. I googled a little and fine many articles about accessing the Master from the ContentHolder, but I believe its no my case...
Here is my situation: I have a user control that has a menu in it. This user control sits on my master page. It is my main navigation menu for my application. I am having an issue where, on one of my pages, users seem to be leaving the page before committing all changes to the database, which results in a loss of data. So what I want to accomplish is - if the user is leaving this page and the data has not been saved yet, I want to prompt the user and say something like "The information is not yet saved, are you sure you want to leave this page" in a modal popup. So my approach is this: In my menu user control, create an event handler called MenuClicked that is raised when the menu web control's (in the user control) MenuItemClicked is raised, I raise my custom MenuClicked event. Then on my master page, I can catch this event in NavMenu_MenuClicked. My problem is - I need to catch this event in my content page, not the master? Am I approaching this correctly?
I've to fix an old ASP.NET application's appearance so that it can conform to the new web visual identity of my organization. The old application does not have any master page and uses a very basic .include file. Modifying the .include header does not change the overall look of the app's pages much, and I still have to manually import new css definitions, replace the table tags with divs on the 60 odd .aspx pages.How should I proceed? I have long term maintainability in mind, so a master page is the obvious solution.
I have a master page that contains the main site navigation and a child master page that contains a secondary menu. I want to set the starting node on the secondary menu based on the selection on the main menu.
I can get the code to work when the menus are on the same page, but when I separate them into their respective master pages, I get an error saying "The name 'SiteMapDataSource2' does not exist in the current context".
I have tried playing around with the FindControl() method, but either it won't work or I'm not getting the syntax right. Most of the information I find is for a child page referencing the master page, but not the other way around.
How can I access the SiteMapDataSource2 control from the master page? If possible, can you include the exact syntax as I am still trying to get the hang of this.
Here is a basic representation of my code, with all of the uncessary stuff stripped out:
I have a custom basepage and a master page in my web application. In my master page, there are events that I run from each page in my web application. Instead of putting the code in each of my pages, I decided to create a base page that each web page will inherit from. Trouble is, I cannot get the base page to invoke the events on the master page.
I have a asp.net webpage which is using an Master page and contentplaceholder.
What is the best sequence order for Page.IsPostBack and User.Identity.IsAuthenticated? From what I have search for, this comes up most common:
If Not Page.IsPostBack Then If User.Identity.IsAuthenticated Then ~Some kind of code~ End If End If
Is this considered "best practice" or can the two items - Page.IsPostBack and User.Identity.IsAuthenticated -be split into their own sections so the fuctions of these can be independent of each other?I am trying to troubleshoot a placeholder that disappears from a master page when a content page button is pressed to change the content pages active view (I have a multiview w/ 5 views inside of it).
I have a FormView and the SELECT statement I have is as follows:
SelectCommand="SELECT [UserName], [Full_Name_1], [Full_Name_2], [Email], [Address], [City], [State], [Zip_Code], [Home_Phone], [Cell_Phone] FROM [Homeowners] WHERE ([UserName]='<%$ User.Identity.Name %>')"... but it results in the FormView disappearing from the web page. Note: at the top of the page, <%= user.identity.name %> displays the name fine, so user.identity.name does contain the info I'm looking for.I am trying to figure out how to correctly format the SELECT filter to feed user.identity.name to the SELECT statement as a filter. ... or if there is an alternative way.
I have a problem i am trying to work out the best method with my limited skills. Im using vb.net(VS 2010) I am using a dll for an IFrame , which is call from code behind. On my site I havea masterpage which has two gridviews. ( GrdViewWebBureau is the one i am using for this query) GrdViewWebBureau is contained within an update panel and updated on a timer control trigger. GrdViewWebBureau updates the page with file counts and status from our clients. I can click on any one of the cells and the code behind is fired. What I am trying to do is put an IFrame on the master page and every time a user clicks on the grid, the Iframe is fired up.
I have tested the iframe and vb code behind from a dummy page and it works, however when the Iframe is on the master page it doeant work. What I am tryingh to achieve is that no matter what page a user is on the site, they will be able to click on the GrdViewWebBureau and the iframe will fire with the correct childpage. Each webPage may also have an Iframe as well, so i dont know if it is possible to make the IFrame global and just call that control ?? I have no idea if 1 this is possible with the code i have and 2, if i have the brains to understand the who what why and when.
i have a masterpage and has some linkbuttons in it, i also have a webform which is a content page for the masterpage. i like to access the controls to the webform via the linkbutton residing in the masterpage or access the linkbuttons via the webform controls.
I am developing a small application in asp.net (writing in c#). In my application I am using jquery to perform asynchronous call to the server. I have an http handler that listens in to the requests and does what it needs to do.
Problems start when in the handler I need to access information stored in the page , from where the asynchronous call started. When I try this:
I have a master page with a textbox that I want to use for a search, and display the results on the content page.
I've dragged in the datasource to the content page, and configured the formview to use that datasource... almost.
The issue I'm having is that on the last step of the configure datasource wizard where you select the parameters, I want to select the master page textbox control for the search parameter... but of course it's not available in the list. The list only allows me to choose controls from the content page.
How do I set this master page search box as the parameter for my datasource?