Web Forms :: Divide The Navigation Of Site Between 2 Menus?
Jan 4, 2010
i want to display my navigation in 2 horizontal menus, one on the top, the other on the bottom. I also want to use sitemap since it ease the maintenance of links. Is there a simple way to achieve this ? (I am not talking about Parent child, say i want to display the first 8 nodes in up menu and the left in the bottom menu.)
I have a site with a few pages, and I decided to have my navigation button (to go from page to page) on my site.master page so every page looks the same. Two questions:
1. is that the correct thing to do? seems to work fine, I'm just not sure if it is proper or not.
2. with the navigation/buttons being on the site.master. How can I pass an "id" from one page to another.
I want the postbackurl to be "~/Inbounds.aspx?id=" a value from a textbox on the page you are leaving. More or less to pass a company name or ID number from page to page, so the queries know who the "owner" is?
I am having difficulties combing site navigation & securityTrimmingEnabled together.Please see my code below, let me know what am I missing:web.config file:
in one of my page i need to display the menus & sub menus dynamically,for this i have a menu table called colleges & one more table called branchs 1] ABC Science ArtsCommarce2] EFG mathszoology historylike thissome times the menus are 3some times they may be 4,5,6 may randommy incresesfor this i have the two table one is menu & sub-menus
I'm currently writing a web app in ASP.NET MVC 1.0 (although I do have MVC 2.0 installed on my PC, so I'm not exactly restricted to 1.0) -- I've started with the standard MVC project which has your basic "Welcome to ASP.NET MVC" and shows both the [Home] tab and [About] tab in the upper-right corner. Pretty standard, right? I've added 4 new Controller classes, let's call them "Astronomer", "Biologist", "Chemist", and "Physicist". Attached to each new controller class is the [Authorize] attribute. For example, for the BiologistController.cs
[Authorize(Roles = "Biologist,Admin")] public class BiologistController : Controller { public ActionResult Index() { return View(); } }
These [Authorize] tags naturally limit which user can access different controllers depending on Roles, but I want to dynamically build a Menu at the top of my website in the Site.Master Page based on the Roles the user is a part of. So for example, if "JoeUser" was a member of Roles "Astronomer" and "Physicist", the navigation menu would say:
[Home] [Astronomer] [Physicist] [About]
And naturally, it would not list links to "Biologist" or "Chemist" controller Index page. Or if "JohnAdmin" was a member of Role "Admin", links to all 4 controllers would show up in the navigation bar. Ok, you prolly get the idea... Now for the real question... Starting with the answer from this StackOverflow topic about Dynamic Menu building in ASP.NET, I'm trying to understand how I would fully implement this. (I'm a newbie and need a little more guidance, so please bare with me.) The answer proposes Extending the Controller class (call it "ExtController") and then have each new WhateverController inherit from ExtController.
My conclusion is that I would need to use Reflection in this ExtController Constructor to determine which Classes and Methods have [Authorize] attributes attached to them to determine the Roles. Then using a Static Dictionary, store the Roles and Controllers/Methods in key-value pairs. I imagine it something like this:
public class ExtController : Controller { protected static Dictionary<Type,List<string>> ControllerRolesDictionary; protected override void OnActionExecuted(ActionExecutedContext filterContext) { // build list of menu items based on user's permissions, and add it to ViewData IEnumerable<MenuItem> menu = BuildMenu(); ViewData["Menu"] = menu; } private IEnumerable<MenuItem> BuildMenu() { // Code to build a menu SomeRoleProvider rp = new SomeRoleProvider(); foreach (var role in rp.GetRolesForUser(HttpContext.User.Identity.Name)) { } } public ExtController() { // Use this.GetType() to determine if this Controller is already in the Dictionary if (!ControllerRolesDictionary.ContainsKey(this.GetType())) { // If not, use Reflection to add List of Roles to Dictionary // associating with Controller } } }
Is this doable? If so, how do I perform Reflection in the ExtController constructor to discover the [Authorize] attribute and related Roles (if any) ALSO! Feel free to go out-of-scope on this question and suggest an alternate way of solving this "Dynamic Site.Master Menu based on Roles" problem. I'm the first to admit that this may not be the best approach.
am wondering how to do the following... I have a registration system. When the user successfully registers, he is then led down a series of data gathering pages (for his profile) and then,finally, ends on his profile's home page where he can start to use the site. All this happens without ever logging into the system so, he is unauthenticated and unconfirmed. My question is, how does this happen? How can I allow my user to be unauthenticated (and unconfirmed, but this I understand) and use all aspects of the Web site? The way I have things set up right now, my code should be doing this:
case CreateProfileStatus.Success: //FormsAuthentication.SetAuthCookie(userName, false); Response.Redirect("NextPage.aspx", false);
I am building a project in asp.net 4.0. My navigation will be database driven where i return a datatable from the db containing all the pages of my site, some will be top level while others will be children and sometimes children of children n-times. Im thinking of going down the nested repeater route and databinding from code behind, dynamically generating repeaters for children, but have read that this is not a best practice and should consider the listview control. Im wanting to build a list of links using an unordered list.
I'm using a custom sqlsitemapprovider to get my site hierarchy out of the database and display my navigation. Now, I have the following main (parent) nodes:
Home - Products - News. What I want to achieve is this, suppose you click on products then a subnavigation appears like this:
productGroup1,productGroup2, productGroup3.
But when you click products, no selection was made from the subnavigation, how would I achieve that if someone clicks on products, the first product with content from the first productGroup1 shows up?
To visualize this: I click on Products -> Subnavigaton gets rendered -> PG1 - PG2 - PG3 -> page displays product1 of PG1
Is there as build in manner to accomplish this or how would one create a method to make this work?
P.S.:For my navigation, I'm not using any build in navigation controls, I'm rendering my menu as an html unordered list e.g: <ul><li></li></ul>
I am currently working on a document management system in ASP.NET 3.5 using the Telerik AJAX toolkit. It consists of masterpage with a title banner across the top and a RadTreeview down the left hand side for navigation through the site. The treeview uses a combination of static nodes and dynamic ones. The dynamic nodes are populated via a webservice. When a node is clicked the relevant page is navigated to, reloading the masterpage and displaying the content of the target page.
The problem comes from the fact the treeview's dynamic nodes are populated via a webservice and therefore as the user navigates through the tree to find a document the treeview behaves as you would expect. However, when you get to the bottom of a tree of dynamic nodes the navigation to the page of the navigateurl causes the relevant page to be loaded and then the treeview resets itself to a collapsed state. This means the user could be deep in a nest of documents but when they view one, the tree collapses and they have to start their navigation all over again. This limitation is not going to be acceptable from an ease of use perspective.
According to Telerik, this is the designed behaviour for performance reasons - the node only ever worries about populating the next set of nodes and therefore the treeviews state is not remembered in viewstate.
So, the meat of question is. Is the masterpage/async treeview navigation design pattern a valid one? Are there any other ways to have an ajax treeview on a masterpage, that remembers it's state when another page is navigated to? I have considered a siglepage/updatepanel/partial page rendering model but the opinions I've seen on the net infer that this is bad idea. It confuses users that expect back/forward browser behaviour to navigate through the site but in a single page world they would end up leaving the site.
I also thought that maybe using a single page container and an iframe may work but this seems to be moving away from the "standard" design pattern of using masterpages.
on left side i have a Tree Control on the basis of that i have to refresh the right side details element into div. Scrolling tree should not disturbed the right side elements as well as right side details should not scroll the page or tree control scrolling.
i have a web page and what i was wanting to do is divide it into lets say 4 quadrants, and in each quadrant i have a control ( a gridview whaich has data dound to it) .
when a user clicks on lets say one of the four the grid does a drill down and display the results in that particular quadrant only while the others are left untouchd .,
id name 1 a 2 b 3 c 4 d ............................ ...................... ..................... 31.......... x
how to divide in two table i means one table left side and second is right side
Left side 1........................a ....................... 16.....................m right side 17.....................n ......................... ....................... 31.........................x
I've got some code which is working as it should but it just seems like a bit of a round about way in doing it and how to tidy it up
Here's my code
Dim TotalNumber As Double Dim NumberFilled As String NumberFilled = Nothing For x = 0 To drCode2a.Tables(0).Columns.Count - 1 If Not drCode2a.Tables(0).Rows(0)(x).ToString() = "0" Then NumberFilled += drCode2a.Tables(0).Rows(0)(x).ToString() & "-" TotalNumber = TotalNumber + drCode2a.Tables(0).Rows(0)(x).ToString() End If Next Dim delimiters As Char() = New Char() {"-"c} Dim TotalNumberFilled As String() = NumberFilled.Split(delimiters, StringSplitOptions.RemoveEmptyEntries) Dim AverageRating As Double = TotalNumber / TotalNumberFilled.Length Response.Write(NumberFilled & "<br/>" & TotalNumber & "<br/>" & AverageRating)
Basically for my example NumberFilled = "1-2-" and TotalNumber = 3 and AverageRating = 1.5
It shows that 2 columns were filled out and the total they equal is 3 so the average = 1.5
As I said it works like it should but I'd like to tidy up if possible