Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
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
 
Old August 8th, 2010, 05:59 PM
Authorized User
 
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
Default WebPage Error When Run Genres.aspx (p 535 Try It Out)

When I open Genres.aspx in my browser, I get a WebPage Error dialog which says an object was expected. Using the browser to debug, it shows me that the jQuery script entered per step 10 is the cause.

If I remove it, the page displays without error.

I have a screen shot of the error dialog and my browser with the page loaded, but I don't see a way to attach a file.
 
Old August 9th, 2010, 02:34 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I think only admins and authors can ulpoad files. You can upload the file to a shared Internet drive or send it to me (see About the Author in the book for my e-mail address).

But maybe a screenshot isn't necessary. Can you post the markup for the entire page so I can have a look? Please use the Remove Text Formatting button on this forum's message editor toolbar when you paste code from Visual Studio and then wrap the code in a pair of code tags (the # button). Otherwise, the code is pretty much impossible to read.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old August 9th, 2010, 09:30 AM
Authorized User
 
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
Default Code for Genres.aspx

Code:
<%@ Page Title="Planet Wrox - Management - Genres" Language="VB" MasterPageFile="~/MasterPages/Management.master" AutoEventWireup="false" CodeFile="Genres.aspx.vb" Inherits="Management_Genres" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainCopntent" Runat="Server">
   <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
   AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Id" 
   DataSourceID="SqlDataSource1" 
   EmptyDataText="There are no data records to display." CellPadding="4" 
      Font-Names="Calibri" ForeColor="#333333" GridLines="None">
   <Columns>
      <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
         ShowSelectButton="False" ItemStyle-Width="100px" />
      <asp:BoundField DataField="Name" HeaderText="Name" 
         SortExpression="Name" ItemStyle-Width="200px" />
      <asp:BoundField DataField="SortOrder" HeaderText="SortOrder" 
         SortExpression="SortOrder" />
   </Columns>  
</asp:GridView>
<br />
   <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" 
      DefaultMode="Insert" Height="50px" Width="125px" AutoGenerateRows="False" 
      Font-Names="Calibri" DataKeyNames="Id">
      <Fields>
         <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="false" 
            ReadOnly="true" SortExpression="Id" />
         <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
         <asp:BoundField DataField="SortOrder" HeaderText="SortOrder" SortExpression="SortOrder" />
      </Fields>
   </asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
   ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>" 
   DeleteCommand="DELETE FROM [Genre] WHERE [Id] = @Id" 
   InsertCommand="INSERT INTO [Genre] ([Name], [SortOrder]) VALUES (@Name, @SortOrder)" 
   ProviderName="<%$ ConnectionStrings:PlanetWroxConnectionString1.ProviderName %>" 
   SelectCommand="SELECT [Id], [Name], [SortOrder] FROM [Genre]" 
   UpdateCommand="UPDATE [Genre] SET [Name] = @Name, [SortOrder] = @SortOrder WHERE [Id] = @Id">
   <DeleteParameters>
      <asp:Parameter Name="Id" Type="Int32" />
   </DeleteParameters>
   <InsertParameters>
      <asp:Parameter Name="Name" Type="String" />
      <asp:Parameter Name="SortOrder" Type="Int32" />
   </InsertParameters>
   <UpdateParameters>
      <asp:Parameter Name="Name" Type="String" />
      <asp:Parameter Name="SortOrder" Type="Int32" />
      <asp:Parameter Name="Id" Type="Int32" />
   </UpdateParameters>
</asp:SqlDataSource>
<script type="text/javascript">
   $(function()
   {
      $('.GridView tr:odd:not(.GridViewPagerStyle)').addClass('GridViewAlternatingRowStyle');
   });
</script>
</asp:Content>
 
Old August 9th, 2010, 09:49 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

That looks pretty good to me.

Maybe you forgot to link the jQuery file as explained in step 8? Or you added it to the wrong file?

I can copy your code into my page, and it runs as expected (except for the placeholder ID which I had to rename to cpMainContent), so the page is OK and the problem must be elsewhere.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old August 9th, 2010, 01:18 PM
Authorized User
 
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
Default Management.master file in error

I had the jQuery script line WITHIN the content placeholder, not below it! (And I don't know how that typo happened with the cpMainContent, but that's fixed too.)

All works now. But the page is hard to read, it is all dark grey with the gridview text just slightly darker. Do I have a style problem, or should I move on and this will be changed later?

Thanks for the help!
The Following User Says Thank You to jlransford For This Useful Post:
poduska (December 12th, 2010)
 
Old August 10th, 2010, 02:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Maybe you have the Monochrome or DarkGrey theme applied as well? Is your admin page inheriting BasePage maybe (maybe you accidentally used your own exported template to create the admin page(s) )

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 15 - JQuery Error in Genres page torr6420 BOOK: Beginning ASP.NET 4 : in C# and VB 1 May 17th, 2010 10:07 AM
Chap 15 pg 535: SMTP error (requires secure connection, authentication and ssl) tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 8 July 19th, 2009 04:10 AM
displaying html in a .aspx webpage badgolfer ASP.NET 1.0 and 1.1 Basics 0 February 22nd, 2005 10:50 AM
Cookie Error when run web page test.aspx C#.net minhpx General .NET 1 August 10th, 2004 01:23 AM
Occur error when run aspx file bapechun ASP.NET 1.0 and 1.1 Basics 11 May 19th, 2004 07:24 AM





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