SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Some Clerifcation on this code

    Hi I am going through a book called:

    Build Your Own ASP.NET 2.0 Web Site Using C# & VB, 2nd Edition
    By Cristian Darie & Zak Ruvalcaba

    and I have a couple questions.

    Question 1:

    Am I understanding this right with SiteMapDataSource that it is sort of a bridging from your web.sitemap file to your tree list,menu,breadcrumb controls? So that information in the sitemap can be put into the menu?

    Question 2:

    The book has this code:

    PHP Code:
    <div class="Menu">
           <
    asp:SiteMapDataSource ID="dorknozzleSiteMap" runat="server" ShowStartingNode ="false" />
           <
    asp:Menu ID="dorknozzleMenu" runat="server" DataSourceID="dorknozzleSiteMap">
            <
    StaticItemTemplate>
                <
    img src="Images/book_closed.gif" alt="+" width="16" height="16" style="border-width: 0;" />
                   <%
    # Eval("Text") %>
            
    </StaticItemTemplate>
           </
    asp:Menu>
        </
    div
    I don't understand what the StaticItem Template really does and I don't understand what <%# Eval("Text") %> is for.

    Question 3

    When I finish this book what should the next book be? I want to do asp with C# and this book is really great but it is an absolute beginner book(what I needed).

    But after I am done I would like to get a intermediate book(not sure if the author has a book what continues on from this book).

    Also should this book me more a C# book? or an asp with c# type book?

    I did a bit of java so I can follow read simple C#(and know about inheritance,overloading,etc) code but I am sure if it would benefit me to get a pure C# book after I finish this book. If I would do that though I would rather have a book what focuses the C# for the web and not applications.

    Thanks

  2. #2
    Non-Member
    Join Date
    Aug 2006
    Location
    Kansas City
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but since it is not natively supported (to add an image) you have to dynamically add it.

    For example (not full code):

    <div class="Menu">
    <asp:SiteMapDataSource ID="dorknozzleSiteMap" runat="server" ShowStartingNode ="false" />
    <asp:Menu ID="dorknozzleMenu" runat="server" DataSourceID="dorknozzleSiteMap">
    <siteMapNode url="default.aspx" title="Home" description="The home page" imageUrl="home.gif">

    </asp:Menu>
    </div>



    public void OnItemBound(object sender, MenuEventArgs args) {
    args.Item.ImageUrl = ((SiteMapNode)args.Item.DataItem)["imageUrl"];
    }

    To dynamically create the image....


    DEFENTLY look up WROX and APRESS ASP.NET books! Far superior then the one you are using.

    They have a book for EVERY topic you could want (Beginning, OOP, Database, Web Parts, XML-ASP.NET, E-Commerce...ect.)

    BTW, I don't work for either company. Just very good books.

    Also, I recommend you buy them off www.bookpool.com , Cheapest computer-related books around. Cheaper then Amazon.

    Again, I dont work for them.
    Last edited by KCChiefs; Aug 3, 2007 at 18:07.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by KCChiefs View Post
    <div class="Menu">
    <asp:SiteMapDataSource ID="dorknozzleSiteMap" runat="server" ShowStartingNode ="false" />
    <asp:Menu ID="dorknozzleMenu" runat="server" DataSourceID="dorknozzleSiteMap">
    <siteMapNode url="default.aspx" title="Home" description="The home page" imageUrl="home.gif">
    <%# Eval("Text") %>
    </asp:Menu>
    </div>



    public void OnItemBound(object sender, MenuEventArgs args) {
    args.Item.ImageUrl = ((SiteMapNode)args.Item.DataItem)["imageUrl"];
    }


    DEFENTLY look up WROX and APRESS ASP.NET books! Far superior then the one you are using.

    They have a book for EVERY topic you could want (Beginning, OOP, Database, Web Parts, XML-ASP.NET, E-Commerce...ect.)

    BTW, I don't work for either company. Just very good books.

    Also, I recommend you buy them off www.bookpool.com , Cheapest computer-related books around. Cheaper then Amazon.

    Again, I dont work for them.
    Any recommendations of which books I should look at from those companies? like what books would be good for my skill level.

    Also I don't get what your trying to say with your code.

  4. #4
    Non-Member
    Join Date
    Aug 2006
    Location
    Kansas City
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I corrected my code.
    Ok, in the code you are creating a "custom" property. ASP.NET doesn't support adding the image. So, you are "extending" its capabilities. So, in turn, you will add an image to each node you declare in the .aspx page. If you ever want to add or remove a node you just delete it in the .aspx page.

    The OnItemBound method (event - In the code-behind) will override what will be displayed in the sitemap. So, it will add an URL (with the title as the text to the link) with an image with it. With the "override" in the code-behind.

    Yeah, I will hook you up with a book list as soon as I can.

  5. #5
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One thing you are misunderstanding I think is that you are trying to separate C# from .NET. C# for the web is ASP.NET - you can't separate them. Of course there are other languages that can be used with ASP.NET, such as VB.NET etc, but you have to use some language, and that language just can't be removed from the .NET framework. So learning ASP.NET is what you'll need for C# on the web; you'll just have to learn the syntax of C#, which is very similar to java so you really shouldn't have a problem.

    Re: Question 1, you're right about your understanding of the site map. A data source is something that provides some sort of access to data, whether it be a database or an XML file. The SiteMapDataSource provides access to the site map. The Menu, TreeView, and SiteMapPath controls can use this provider to display their data.

    As for reading, there's nothing better you can do than to download the MSDN library. that's the sole method I used for learning the .NET framework. Also the quick start tutorials are helpful.

  6. #6
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chobo2 View Post
    I don't understand what the StaticItem Template really does and I don't understand what <%# Eval("Text") %> is for.
    Some menu items are always visible (the static nodes), while others (the dynamic ones) "pop out" when you mouse over their parent item.

    The menu control - like many other controls - comes with built-in templates. To allow developers to custimize the menu items the control allow you to override the built-in templates.

    The code overrides the template for the static items. The content of the template will be used for every static item.

    The Eval("Text") merely gets the .Text property of the sitemao node. Likewise, Eval("Url") would get the url.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by devbanana View Post
    One thing you are misunderstanding I think is that you are trying to separate C# from .NET. C# for the web is ASP.NET - you can't separate them. Of course there are other languages that can be used with ASP.NET, such as VB.NET etc, but you have to use some language, and that language just can't be removed from the .NET framework. So learning ASP.NET is what you'll need for C# on the web; you'll just have to learn the syntax of C#, which is very similar to java so you really shouldn't have a problem.

    Re: Question 1, you're right about your understanding of the site map. A data source is something that provides some sort of access to data, whether it be a database or an XML file. The SiteMapDataSource provides access to the site map. The Menu, TreeView, and SiteMapPath controls can use this provider to display their data.

    As for reading, there's nothing better you can do than to download the MSDN library. that's the sole method I used for learning the .NET framework. Also the quick start tutorials are helpful.
    I know without C# the ASP would not be doing much. I am just trying to find a book that sort of teaches both of them at the same time(becuase with a pure C# book they would and make applications I don't really want to do that). Even though the sytanx might be the same as Java I might know when to use what stuff(yes I could search through the msdm but if I don't know something exists it will be alot harder to find) but if I have a book and shows you common things what you can do with the asp and pair it up with the C# I will be able to take it from there and expand on it.

    Like for an example when I make my first practice website I want to make to have a section where you will have say:

    5 check boxes with 5 images. The user then selects the say 3 out of those 5 images then it takes those and goes to another page. There the user will see randomly one of these images and will have to type in the correct answer in a text box(so if it a picture of cat they write cat).

    Right now I have a sort of an idea of how it will work but not even to actually see a working model in my mind.

    Problems I see are

    1. How to bind the selection box to an image(never worked with selection boxes before)
    2. How to put them into the random generator
    3. how to label these images so when cat appears that the program know that if they put cat in it is right if anything else it is wrong

    and that would just a be a couple problems.

    Thanks all for your posts so far they been quite helpful.

  8. #8
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is a C# language reference and tutorial in the MSDN library, in case that might help. I don't have the link off-hand though.

    Also those quickstarts show you many things you can do with ASP.NET.

    By the way, it's standard to refer to it as ASP.NET. ASP refers to classic ASP, which is very different than ASP.NET.

  9. #9
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would still like to see KCChiefs book list and any other recommended books but I am beginning to think that after I finish reading my book I should just start making a website and when I run into something I don't know how to do then read the chapter in one of the books.

    Do you think this would be a better way to learn that way your making something you want to make and at the same time learning the skills. Like I am starting to think if I got through chapter by chapter and just do there short examples in the books will I really remember all of it by the time the book is done.

    I would really like to hear what you guys went about learning .net and C#.

  10. #10
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would like to recommend

    Introducing Microsoft ASP.NET 2.0, Dino Esposito, Microsoft Press

    It takes you through Master Pages, Web Parts, user profiles, themes and skins, security, the rich (coarse grained) controls etc.

    I've had both really good Wrox books, but also some really bad ones. Be sure to read the reviews.

    For C# I just jumped in. The book I used is outdated by now. I would recommend that you pick up a book which also covers C# 3.0. They are bound to be out soon, as C# 3.0 will be released with VS2008 at the end of the year. C# 3.0 is a major extension of the language which will change how we write much of our programs.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •