Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 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 January 10th, 2009, 09:50 AM
Authorized User
 
Join Date: Dec 2008
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default chapter10

Hi,
Sorry for disturbing again. Now some problem with Chapter 10, Using the New control
TIO(page 375).
Ther first point suggested that- "Open Visual Developer and select Open website
.From the Chapter10 folder (C:\BegASPNET2\Chapters\Begin\Chapter10),Select WroxUnitedNewsControl and
click OK." Now the problem is that in Chapter10 there is no folder named as WroxUnitedNewsControl.
Chapter 10 folder contains NewsUserControl,ObjectDataSource,SimpleUserControl ,TestCodeBehind and WroxUnited folders only.
So I have tried that TIO in NewsUserControl folder.
But when I run the NewsDisplay.aspx , it is not showing anything rather than a blank page.

The codes are as follows:
NewsUserControl.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="NewsUserControl.ascx.cs" Inherits="NewsUserControl" %>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:WroxUnited %>" ></asp:SqlDataSource>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<div class="newsItem">
<span class="newsDate"><%#Eval("DateToShow","{0:dd MM yyyy}") %></span>
<span class="newsTitle"><%#Eval("Title") %></span>
</div>
<span class="newsContent"><%#Eval("Description") %></span>
</ItemTemplate>
</asp:Repeater>


NewsUserControl.ascx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class NewsUserControl : System.Web.UI.UserControl
{
private int _itemsToShow = 5;
public int ItemsToShow
{
get
{
return _itemsToShow;
}
set
{
_itemsToShow = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Repeater1_PreRender(object sender, EventArgs e)
{
string sel = string.Format("SELECT Top {0} * FROM [News] WHERE DateToShow <= '{1}' ORDER BY DateToShow DESC", _itemsToShow, DateTime.Now.ToString("yyyy/MM/dd"));
//Make sure above is all on one line.
SqlDataSource1.SelectCommand = sel;
}
}

NewsDisplay.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewsDisplay.aspx.cs" Inherits="NewsDisplay" %>
<%@ Register Src="NewsUserControl.ascx" TagName="NewsUserControl" TagPrefix="uc1" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:NewsUserControl ID="NewsUserControl1" runat="server" />

</div>
</form>
</body>
</html>


NewsDisplay.aspx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class NewsDisplay : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

&nbsp;</div>
</form>
</body>
</html>

Default.aspx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}


web.config:

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings>
<add name="WroxUnitedConnectionString" connectionString="Data Source=LOCALHOST\SQLEXPRESS;AttachDbFilename=C:\Be gASPNET2\Chapters\Begin\Chapter10\NewsUserControl\ App_Data\WroxUnited.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="WroxUnited" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\WroxUnited.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>



Thanks in advance.

Regards,
jackSparrow





Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter10: reference not set... JohnBoy BOOK: Beginning VB.NET Databases 2 May 1st, 2006 05:34 AM
Another question on Chapter10 czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 10 March 31st, 2005 03:11 PM
error on Chapter10 yc5x BOOK: Beginning Java 2 2 September 7th, 2004 11:57 AM
chapter10 yc5x BOOK: Beginning Java 2 1 August 28th, 2004 05:21 AM





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