开发者

Make Sectioned Page Content

This question is pretty difficult for me to phrase well, so please bear with me.

In VS Express I'm creating a series of web pages. On each page I want there to be a series of functions, relevant to a given user role. I want all my html code on a single aspx page, but with only certain sections appearing (hopefully asynchronously) as determined by 开发者_如何学Pythonthe url which will be linked to via a drop down menu in the navbar.

I would like to use Rerouting (I think it's called) to keep my urls nice and more malleable so I can change them later without breaking bookmarks and such.

As a user, in a given role, I would mouse over the drop-down menu and see only the functions which I am allowed to perform. Upon clicking on one, it would update the url something like domain.com/form1 and would only show the block of code (in the aspx page, and again, preferably asynchronously) relevant to that action.

I'm thinking to use divs and the css "display:none;" property. I'm not not sure by what mechanism to toggle between the "views," if you will, of the various functions. Should I use Javascript of ASP.NET?

I'm so sorry for such a convoluted question. I spent over 20 minutes and this is the best way I could figure to ask. Does this even many any sense? If so, am I going about this all wrong or am I on the right track? I appreciate any stabs at this.

Cheers ;)

PLEASE READ: I originally wanted to accomplish this with the urls, but I found that using the "MultiView" ASP.NET control is was a much better solution to my dilemma. I just wanted to clear up any presumed discrepancy between my original question and my answer. Like I said, it was a difficult question to figure out how to ask at the time. :)


It's actually called URL rewriting. There is a few way to achieve that, the easier might be the wizard in IIS.

As for all your html in a single page, you could use panels and change their visibility when needed.


Being somewhat new to .NET and especially ASP.NET, I'm learning new things everyday, literally. I've recently discovered the "Multiview" control, which is amazing. I've used it for creating multiple menu bars (I know this seems wierd, but it's to simulate different user "modes" or user groups, etc), as well as the combining of content onto a single page as I mentioned in my original question. I then added a secondary control for toggling between the menus. Here is some sample code for how I implemented the control for my multi-menubar :P

<asp:MultiView ID="MenuView" runat="server">
    <!-- ADMIN GROUP -->
    <asp:View ID="View0" runat="server">
        <asp:Menu ID="adminNav" runat="server" CssClass="menu" IncludeStyleBlock="False" Orientation="Horizontal"><DynamicMenuItemStyle />
            <Items>
                <asp:MenuItem NavigateUrl="~/Reports.aspx" Text="View Reports" />
                <asp:MenuItem NavigateUrl="~/Approve.aspx" Text="Compliment hard-working employees" />
                <asp:MenuItem NavigateUrl="~/Promote.aspx" Text="Promote the qualified employees :)" />
                <asp:MenuItem NavigateUrl="~/Fire.aspx" Text="Send underlings home to starving children" />
            </Items>
        </asp:Menu>
    </asp:View>
    <asp:View ID="View1" runat="server">
    <!-- USERS -->
        <asp:Menu ID="userNav" runat="server" CssClass="menu" IncludeStyleBlock="False" 
            Orientation="Horizontal"><DynamicMenuItemStyle />
            <Items>
                <asp:MenuItem NavigateUrl="~/Work.aspx" Text="Look productive" />
                <asp:MenuItem NavigateUrl="~/Complain.aspx" Text="Complain about boss" />
                <asp:MenuItem NavigateUrl="~/Praise.aspx" Text="Show appreciation for your awesome boss" />
            </Items>
        </asp:Menu>
    </asp:View>
</asp:MultiView>
<!-- MODE MENU -->
<asp:DropDownList ID="modeMenu" runat="server" AutoPostBack="True" 
    ViewStateMode="Inherit" CssClass="modeMenu" EnableViewState="True">
    <asp:ListItem>Admin</asp:ListItem>
    <asp:ListItem>User</asp:ListItem>
</asp:DropDownList>

Code Behind for controlling "MenuView" with "modeMenu" dropdown which I have as "position:fixed; left:5px; top:5px;" in my CSS to keep it out of the way.

Protected Sub mode(ByVal sender As Object, ByVal e As System.EventArgs) Handles modeMenu.Load, modeMenu.SelectedIndexChanged
    Session.Add("mode", modeMenu.SelectedValue) //I use a session variable to maintain the state of the menu.
    Select Case (modeMenu.SelectedValue)
        Case "Admin"
            MenuView.ActiveViewIndex = 0
        Case "User"
            MenuView.ActiveViewIndex = 1
    End Select
End Sub

There you have it. I hope someone else finds this useful. Cheers ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜