 |
BOOK: Beginning ASP.NET 4 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
|
|
|
|
|

May 24th, 2012, 11:04 PM
|
|
Registered User
|
|
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter8-Page 277-step 2-4
I have followed the instruction exactly and the met the problem at the step three.
I dragged the file Banner.ascx from the Controls folder into the design view of the MasterPages/forntend.master below the Drop-down list.
Then I followed the the Step 4, switch to Markup view tried to find the "@ Register" in the top of the file. However, I can not find it and the code in Markupview is not changed. I paste the code as following. I dragged the Banner,ascx to its Design view. You can see there is no the "@ Register" code show up.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Frontend.master.cs" Inherits="MasterPages_Frontend" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div id="PageWrapper">
<div id="Header"><a href="~/" runat="server"></a></div>
<div id="MenuWrapper">
<asp:Menu ID="Menu1" runat="server" CssClass="MainMenu" DataSourceID="SiteMapDataSource1" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False">
</asp:Menu>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ShowExpandCollapse="False">
<LevelStyles>
<asp:TreeNodeStyle CssClass="FirstLevelMenuItems" />
</LevelStyles>
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
</div>
<div id="MainContent">
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
<br />
<br />
<asp:ContentPlaceHolder ID="cpMainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="Sidebar">Select a Theme<br />
<asp:DropDownList ID="ThemeList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ThemeList_SelectedIndexCha nged">
<asp:ListItem>Monochrome</asp:ListItem>
<asp:ListItem>DarkGrey</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Footer">Footer Goes Here</div>
</div>
</form>
</body>
</html>
By the way I use the Visual Studio 2010 Premium.
|
|

May 25th, 2012, 02:22 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Is this the code before or after you dragged the control in the master page? Besides the missing Register attribute, I also don't see the declaration of the control itself. If it's from before, can you post the code for the master page after you dragged the control so I can see what VWD added?
Also, could it be that you're using the book's code that already has the control setup in web.config?
If none of this helps, can you post the markup and code behind for the user control?
Imar
|
|

May 25th, 2012, 10:13 AM
|
|
Registered User
|
|
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
Thanks for paying attention to my question.
As you see the code I posted just the code after I dragged the control to the masterpage. You did not see the declaration of the control itself, which just the problem I meet. I dragged the Banner.ascx to the masterpage on design view, and the banner added successful, then I switch to the markup view, there nothing changed. I requested the Default.aspx in browser, the banner did not show up. However, I switch to the design view of the master page again, the banner still there just below the drop-down list. It is so weird.
I post the code of control and you can make remote control of my computer to see this problem if you want.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Banner.ascx.cs" Inherits="Controls_Banner" %>
<ASP:PANEL ID="VerticalPanel" runat="server">
<a href="http://p2p.wrox.com" target="_blank">
<ASP:IMAGE ID="Image1" runat="server" AlternateText="This is a sample banner"
ImageUrl="~/Images/Banner120x240.gif" />
</a>
</ASP:PANEL>
Thanks
|
|

May 25th, 2012, 02:31 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Are you sure you saved the changes? How exactly are you dragging / dropping the control? It should add at least something like <uc1:Banner .... /> to the page. Where do you drop the control exactly?
Imar
|
|

May 25th, 2012, 02:46 PM
|
|
Registered User
|
|
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I exactly dragged the control from the controls folder and droped it below the Drop-down list in the <div>sidebar</div>. I am sure I did not make any mistake, meanwhile, I use your sample code of Chapter 7 for downloaded Source folder.
Actually I tried these on my friend's computer, and it works! I realize that we using the different version of Visual Studio 2010, I use the Premium and my friend uses Professional.
I just wondering may be the circumstance of my computer rise this problem, but I am not convinced by that.
Thanks a lot and I am so sorry if there any inconvenience I bring!
Best
Bing
|
|

May 25th, 2012, 02:52 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
I use the Premium and my friend uses Professional.
|
That should not make a difference; dropping UCs is a core feature of the IDE and is supported in all versions, including the free Express edition.
Quote:
|
I am so sorry if there any inconvenience I bring!
|
You didn't, so don't worry ;-)
Cheers,
Imar
|
|

May 27th, 2012, 01:52 PM
|
|
Registered User
|
|
Join Date: May 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If you're dragging and dropping in design view and it shows up in design view but does not show up in markup view then possibly the markup view that you're looking at is actually to another file rather than the one that you are expecting.
I had an interesting problem in this section of the book as well where the horizontal banner would not display in the browser no matter what I did (vertical was fine, just not horizontal). I spent a ton of time thinking through it and redoing it but to no avail. Then I had the wild idea to try another browser. My default browser was Firefox and was not displaying the horizontal banner but I found that IE 9 displays it just fine. Maybe something similar is happening in your situation?
Good luck!
|
|
 |
|