Wrox Programmer Forums
|
BOOK: Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages ISBN: 978-0-470-12448-2
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages by Jacob J. Sanford; ISBN: 9780470124482
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages ISBN: 978-0-470-12448-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2007, 06:25 PM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question about masterpages

Hi,

I just finished reading your book and about masterpages and it was great.
Im working on a project and i dont know how i will do the design.
I was thinking of using masterpage thats why i bought the book :)

But i dont know if this is possible to do with masterpages.
Check out this link bellow so you can see how i want it to work.

http://img64.imageshack.us/my.php?image=designys8.jpg

Link 1-6 will be different gridviews and FormViews.
Link 1-3 is links to the contentplaceholder to the left and Link 4-6 is links to the contentplaceholder to the right.

If Link 1 is a gridview and its showing in the contentplaceholder on the leftside.

And now i click on Link 4 and that is a FormView thats going in the contentplaveholder on the rightside.

Then I want the gridview on my leftside to stay. So when i click on link 4 and pass the querystring into my url for example page4.aspx?ProjectNr=2 i need somehow reload or make my content in my contentplaveholder for the left side to stay.

Is this possible to do with two contentplaceholders?

If not, do you have any idea how i should do it?


 
Old November 27th, 2007, 10:46 PM
Wrox Author
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to surfer5 Send a message via AIM to surfer5 Send a message via MSN to surfer5 Send a message via Yahoo to surfer5
Default

My immediate answer is "anything is possible." :D

I'm thinking through the design your talking about and I am wondering if Master Pages might be overkill. I think you could probably do it but I don't think you would really need to. The Master Page is mostly meant to be a layout structure you apply to multiple pages. It looks like, from the image you showed, that this is more of a page specific issue. Like you will have one page that can display 3 different gridviews for each of 2 different areas on that page. Is that right? I realize I don't know the specifics of your project so it's possible I am off-target. If so, just let me know and I will think about it some more.

Now, with that being said, if I understand your design issue properly, the way I would probably do it is to have two different MultiView controls on the page, and then add a view to the appropriate MultiView control for each of the different views you need (GridView or FormView controls). I would then use LinkButton controls to navigate the MultiView controls. This would look something like this:

Code:
    <table>
        <tr>
            <td align="left">
                <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Grid 1</asp:LinkButton> |
                <asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">Grid 2</asp:LinkButton> |
                <asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click">Grid 3</asp:LinkButton> |
            </td>
            <td align="right">
                <asp:LinkButton ID="LinkButton4" runat="server" onclick="LinkButton4_Click">Grid 4</asp:LinkButton> |
                <asp:LinkButton ID="LinkButton5" runat="server" onclick="LinkButton5_Click">Grid 5</asp:LinkButton> |
                <asp:LinkButton ID="LinkButton6" runat="server" onclick="LinkButton6_Click">Grid 6</asp:LinkButton> |
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:MultiView ID="MultiView1" runat="server">
                    <asp:View ID="View1" runat="server">Grid 1:<br /><asp:GridView ID="GridView1" runat="server" /></asp:View>
                    <asp:View ID="View2" runat="server">Grid 2:<br /><asp:GridView ID="GridView2" runat="server" /></asp:View>
                    <asp:View ID="View3" runat="server">Grid 3:<br /><asp:GridView ID="GridView3" runat="server" /></asp:View>
                </asp:MultiView>
            </td>
            <td align="right">
                <asp:MultiView ID="MultiView2" runat="server">
                    <asp:View ID="View4" runat="server">Grid 4:<br /><asp:GridView ID="GridView4" runat="server" /></asp:View>
                    <asp:View ID="View5" runat="server">Grid 5:<br /><asp:GridView ID="GridView5" runat="server" /></asp:View>
                    <asp:View ID="View6" runat="server">Grid 6:<br /><asp:GridView ID="GridView6" runat="server" /></asp:View>
                </asp:MultiView>
            </td>
        </tr>
    </table>
I'm just using some tables for demonstration purposes. You could easily do the alignment and such in CSS (which is what I would do in a real project - I just didn't want to get into all of the CSS code to dilute this example).

In the code-behind, you would need methods for each of the OnClick events in the LinkButton controls used to navigate the views in the MultiView control. This would probably look something like this:


Code:
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            MultiView1.ActiveViewIndex = 0;
        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            MultiView1.ActiveViewIndex = 1;
        }

        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            MultiView1.ActiveViewIndex = 2;
        }

        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            MultiView2.ActiveViewIndex = 0;
        }

        protected void LinkButton5_Click(object sender, EventArgs e)
        {
            MultiView2.ActiveViewIndex = 1;
        }

        protected void LinkButton6_Click(object sender, EventArgs e)
        {
            MultiView2.ActiveViewIndex = 2;
        }
As you can see, when you click on LinkButton1, it fires off the LinkButton1_Click method, which sets the index of the active view of MultiView1 to zero (0).

Now, if you wanted to be really cool about it, I would wrap all of that functionality inside of an AJAX UpdatePanel so that the MultiView controls are updated without any screen flicker. But that's just me. :)

Hope this helps. If I didn't quite nail what you were getting at, please don't hesitate to reask.

Oh, and thanks for reading the book!

-Jacob

01000111
01000101
01000101
01001011
 
Old November 29th, 2007, 03:54 AM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You nailed it, thats exactly how I want it to look and work.

The only problem i can think of now is that I will have most of the project in one aspx file.
Not sure if it´s possible but maybe I can have the diffrent gridviews in seperate files.

Thanks Jacob.

/Kjella

 
Old November 29th, 2007, 11:42 AM
Wrox Author
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to surfer5 Send a message via AIM to surfer5 Send a message via MSN to surfer5 Send a message via Yahoo to surfer5
Default

Well, what you might consider doing is wrapping all of the items to be displayed (GridView and FormView controls) into seperate Web User Controls. That way, all of the code/databinding/etc for each control would be done in the code of the web user control for that page.

For example, let's work through this for GridView1 created in the previous example. Create a new web user control called "GridView1.ascx" that has the following code (this is all of the code at this point):

Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GridView1.ascx.cs" Inherits="wroxMPquestion.GridView1" %>
Grid 1:<br /><asp:GridView ID="GridViewDetails01" runat="server" />
Your code may be slightly different because my project I was using to test out my code was called wroxMPquestion, which you can see referenced in the Inherits property. That first line SHOULD be added for you when you add a new web user control so I wouldn't spend much time obsessing about it. However, if you noticed the discrepancy, I wanted to make sure that you knew it was intentional.

Next, you will need to go back to your page and add a reference to the web user control by adding the following line directly under your @Page directive:

Code:
<%@ Register TagPrefix="GV01" TagName="GridView1" Src="~/GridView1.ascx" %>
The TagPrefix and TagName are flexible (name them what you want but make sure they are something that is intuitive because you will be using it in the next step).

Now modify the view we created earlier for GridView1 to look like this:

Code:
<asp:View ID="View1" runat="server"><GV01:GridView1 runat="server" ID="GridViewWebUserControl1" /></asp:View>
You can see that you are using "GV01" and "GridView1" that you created in the tag reference declaration to instantiate this web user control. The only other things that you are doing are providing the runat property and giving it an ID.

Doing it this way will keep you main page (the one with all of the views) much more sleek and readable (much less code). It will allow you to put all of your code-behind and formatting of your various controls (GridViews and FormViews) in the user controls themselves so that it doesn't clutter up your main page. This will also allow you to reuse the GridView and FormView control in other pages if you need them simply by pulling in the web user control.

Plus now you have like 7 pages instead of 1. :)

-Jacob

01000111
01000101
01000101
01001011





Similar Threads
Thread Thread Starter Forum Replies Last Post
masterpages, contentplaceholder, formview, button miltonsnider ASP.NET 2.0 Basics 5 December 4th, 2007 01:17 PM
error in source while using masterpages dotnetuser ASP.NET 2.0 Basics 4 June 28th, 2007 08:10 AM
Problems with MasterPages gobotsoup ASP.NET 2.0 Basics 2 March 7th, 2007 11:48 AM
MasterPages ContentPages and Meta tags michaelcode ASP.NET 2.0 Basics 5 June 1st, 2006 04:13 PM
MasterPages Help! polonskyg ASP.NET 2.0 Basics 1 March 24th, 2006 12:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.