 |
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
|
|
|
|
|

August 8th, 2010, 05:59 PM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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.
|
|

August 9th, 2010, 02:34 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

August 9th, 2010, 09:30 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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>
|
|

August 9th, 2010, 09:49 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

August 9th, 2010, 01:18 PM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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:
|
|
|

August 10th, 2010, 02:59 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
 |
|