Building menus dynamically in ASP.Net - asp.net

I have created a site which has some roles. and each user can have some roles. every role has permission to some pages.
I want to build menus dynamically depending on user roles so every user can see his available pages in his menu.
I want to know that what is the best way to do this? using an XML to describe this menus hierarchy and specify each role available menus or there is better way to do this?

Rather than reinventing the wheel, I'd strongly suggest using Telerik's Extensions for ASP.NET MVC.
It includes a powerful Menu extension and has good programmability. I've used the .Visible() method along with IPrincipal.IsInRole() to determine which menus are available and when.
What's better is that it's free and open source! There's a paid-for version with support, but community and forum support seems to be quite good enough.

we have a mysql database that has the roles and objects and a decision is made at run time based on the logon user as to who gets to see what. There is also a decision made on individual pieces or controls on the page. There can also be tests on the pages themselves to make sure it's not just a menu that's hiding a page.

I used the MVC sitemap project in combination with a "Security Trimming" link helper ( "Security aware" action link? ) for this sort of thing before. Pretty easy.

Related

Implement adding content only by some pople. Rails

I am working on dictionary-like web page and I want to implement adding/changing phrases only by few people (my client - which is some small organisation wants to be able to do this by himself). The page does not have any login/registration mechanism etc. (for regular users at least) so I do not want It to have any login button. I wondered if making admin model ( few admins made in seeds for example) and adding login button that is invisible - I thought of using CSS opacity for this one. Is this a good solution ? Is there any other good practice in these sitations? Please dont be afraid to post suggestions. Additionally this is a serious page (my first job as freelancer), so I wonder if my solution is... acceptable? Thanks in advance for any answers!
This quite a standard thing in the web. Most of the websites consists of two parts, customer facing part (sometimes called frontend) and admin panel (called backend). In your case you don't need any login to access frontend part, but you need one for backend part.
Creating hidden button is not needed at all. There simply should be no button at all. If you want to log in as an admin, you simply navigate to http://my-website-url.com/admin.
I wouldn't bother with roles et unless your client specified clearly that he needs them.
Even though this is simple I would still suggest adding a role to a user model. After all he may want to have some user functionality later on. The simplest way to do this would be to use devise and add a role enum column.
Check out the article below and look under the "Enum" section.
http://railsapps.github.io/rails-authorization.html

Drupal module development examples

I'm new to Drupal, but I want to create an add-on. The add-on requires some sort of multi-page form with advanced jQuery (I already looked at the jQuery module).
The add-on requires details of the current logged in user and will also communicate with an external database.
I've been looking at tutorials concerning Module creation etc. But they mostly cover creation of simple forms, where as what I want to create is more of a plugin.
Multi page forms are a total drag. Pro Drupal Development, has a very good section on this topic, and I highly recommend that book if you are doing any Drupal development.
Online I found the following article pretty useful too (though I ultimately went with my own system).
http://www.nicklewis.org/using-chaos-tools-form-wizard-build-multistep-forms-drupal-6
There's a decent example here:
http://thedrupalblog.com/creating-multipage-form-using-forms-api
To make the most out of this, you're going to want to get pretty friendly with the Form API:
http://drupal.org/node/204270
Sadly Drupal.org seems to be missing a Drupal 6.x explanation (though plenty exist for 5.x and 4.7 oddly enough).
Multi step forms are complex by nature, but there are some methods to make it easier. I recommend that you have a look at the multistep form tools offered by the Ctools module. This blog post by Nick Lewis explains how you can use it.
I think you should think twice before going with javascript/jQuery to create your forms. Javascript is a great way to improve the user interface, but it can be easily manipulated because it's client side technology. You shouldn't rely on javascript alone for things like input validation, temporary storage of form values and controlling the flow between different steps of the form.
I feel odd saying this, but I don't think you want to use the Drupal Forms API.
The Forms API provides a lot of security features (unique token, rebuilds form after submit to compare to ensure correct form is processed, etc.) and allows other modules to modify your forms, but I think a lot of those features will get in the way of your jEditable form. Multi-page forms are not that challenging using the Forms API, but jEditable elements will be.
Your module could simply add a menu item with a page callback function that puts together your jEditable form for you. That is about as close to the world of a 'normal PHP' script as Drupal will let you get.

How to allow users to create or edit web forms within a Spring MVC web application?

We would like to provide our users with a limited set of drag-n-drop fields so they could manage template web forms in an application. The admins would define these templates and the users would enter some data up front which would determine which template they would be shown.
Is there a framework or some things I could check out on how to do this?
We use Spring MVC 3 as our web layer and that would drive our solution.
Thanks!
E
I don't know of any frameworks (that would play nicely with Spring MVC 3) that would do what you are describing and the fact that there are no answers after 5 days also suggests this.
Although you could write such a thing yourself, it sounds like a very big and complex undertaking. You might be able to use a Javascript framework like YUI or ExtJS to handle some of the custom form generation but that tends to be client focussed so you then have an issue of persisting the custom form for other users.
In my organisation we use WordPress with the "Contact Form 7" plugin to do just what you describe. Non-coders can create forms in the WP admin interface and when submitted, it results in a custom email which then gets processed by a human or has a link in it that auto-populates params for a custom webapp (that is scary and has many form fields).
My gut feeling is that although the stake holders think they need unlimited variations of forms, they may only really need a few variations of those forms. It might be a lot easier to simply code up a handful of different pages/forms and then have a leading form which takes the user to the form they need.
Also the use of Jquery hide/show can be very useful in hiding optional elements and thus reducing the negative impact of a very complex form in terms of UX (user experience/usability). E.g. the questions the users gets asked can then lead to some form elements being hidden/shown on the page, using Javascript.

ASP.NET Menu: how to build custom menu

i have this situation: i have to build a menu with datasource from the db, because i have to filter them among the user that is loged in. i have tried building a menu using repeater, and all this works fine till i realized that i wanted the menu with more than two levels. i have also tried with treeview, but i really don't want this solution (problem with the style and the treeview doesn't have a pretty view).
Could anyone give me just the idea ?
thnx in advance.
If you are securing your pages in the conventional sense (ie--using ASP.NET's builtin permissions system), you can just use the normal SiteMapProviders as they will security trim menus for you.
If you need to do custom, try making a class that implements IHeirarchicalDataSource and then bind anything appropriate (eg--ASP.BulletedList) to that.

Does someone have real project experience using asp.net mvc implement complicated web UI app?

In my past projects I've been using webform to implement windows form style complicated backend admin page by using asp.net webform.
Just wondering by using asp.net mvc, can it make this kind of complicated UI page much easier?
This highly depends on what UI you need. For me, it wouldn't be easy without jQuery... but with jQuery it's very convenient.
For example of possible nesting, my app has cart that contains Accordion for customers, with each pane containing custom tabs with sliding animations for orders, with each order containing table of items, where each item can be expanded to show included products details (not to mention context menus to change customers, on-the-fly discounts changing with notification tooltips, popups to show product details, and so on). All this on single page. And I still find it very easy to manage, because all the functionality is well split across MVC controllers and views.
As for "admin part", I use two-level nesting (with second level on another page, but I just don't want to go deep into jqGrid), and it's 5 minutes to setup a new admin page using AutoMapper, custom attributes, and some custom code. Got new entity (e.g. SomeProduct)? 5 minutes and new admin page with grid, custom editing controls and formats is done. With MVC.
But if you need traditional "data grid" approach, chances that ASP.NET will do better. Or maybe jqGrid (or third-party grids like Telerik) will help you, because they have subgrids and all this stuff. I would say, if you don't like Domain-Driven Design, if your application is not object/entity driven, but highly based on raw data tables, then MVC might be not what you need. But I may be wrong because I never worked with such applications. All other apps, I'd prefer MVC.

Resources