There are two mistakes in Chapter 31, Using Server-Side ASP.NET AJAX, both related to a last minute change to the ListView control. Microsoft changed the ListView control to require an itemPlaceholder instead of an itemContainer element in its LayoutTemplate. I managed to update the other code samples related to the ListView control in the book, but I neglected to update Chapter 31 (I forgot that I used the ListView control in this chapter).

The correct code for Listing 31.6 is:

   1:  <%@ Page Language="C#" %>
   2:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   3:  <html xmlns="http://www.w3.org/1999/xhtml">
   4:  <head runat="server">
   5:      <title>Nested UpdatePanels</title>
   6:      <style type="text/css">
   7:          fieldset
   8:          {
   9:              padding: 10px;
  10:          }
  11:          .comment
  12:          {
  13:              padding: 10px;
  14:              border: dotted 2px black;
  15:              margin: 10px;
  16:          }
  17:      </style>
  18:  </head>
  19:  <body>
  20:      <form id="form1" runat="server">
  21:      <div>
  22:      <asp:ScriptManager
  23:          id="sm1"
  24:          Runat="server" />
  25:      Page Time: <%= DateTime.Now.ToString("T") %>
  26:      <br />
  27:      <asp:DropDownList
  28:          id="ddlMovie"
  29:          DataSourceID="srcMovies"
  30:          DataValueField="Id"
  31:          DataTextField="Title"
  32:          AutoPostBack="true"
  33:          Runat="server" />
  34:      <asp:SqlDataSource
  35:          id="srcMovies"
  36:          ConnectionString='<%$ ConnectionStrings:con %>'
  37:          SelectCommand="SELECT Id, Title FROM Movie"
  38:          Runat="server" />
  39:      <br /><br />
  40:      <asp:UpdatePanel ID="upOuter" UpdateMode="Conditional" runat="server">
  41:      <Triggers>
  42:          <asp:AsyncPostBackTrigger ControlID="ddlMovie" />
  43:      </Triggers>
  44:      <ContentTemplate>
  45:      Outer UpdatePanel Time: <%= DateTime.Now.ToString("T") %>
  46:      <br />
  47:      <asp:FormView
  48:          id="frmMovie"
  49:          DataSourceID="srcMovie"
  50:          Runat="server">
  51:          <ItemTemplate>
  52:          <fieldset>
  53:          <legend>Movie</legend>
  54:          Title: <%# Eval("Title") %>
  55:          <br />
  56:          Director: <%# Eval("Director") %> 
  57:   
  58:          <asp:UpdatePanel ID="upInner" runat="server">
  59:          <ContentTemplate>        
  60:          <asp:ListView
  61:              id="lstMovieComments"
  62:              DataSourceID="srcMovieComments"
  63:              InsertItemPosition="FirstItem"
  64:              Runat="server">
  65:              <LayoutTemplate>
  66:                  <fieldset>
  67:                  <legend>Comments</legend>
  68:                  Inner UpdatePanel Time: <%# DateTime.Now.ToString("T") %>
  69:                  <asp:PlaceHolder id="itemPlaceHolder" runat="server" />
  70:              </fieldset>          
  71:              </LayoutTemplate>
  72:              <ItemTemplate>
  73:                  <div class="comment">
  74:                  <%# Eval("Comment") %>
  75:                  </div>
  76:              </ItemTemplate>
  77:              <InsertItemTemplate>
  78:              <asp:Label
  79:                  id="lblComment"
  80:                  Text="Comment:"
  81:                  AssociatedControlID="txtComment"
  82:                  Runat="server" />
  83:              <br />
  84:              <asp:TextBox
  85:                  id="txtComment"
  86:                  Text='<%# Bind("Comment") %>'
  87:                  TextMode="MultiLine"
  88:                  Columns="40"
  89:                  Rows="3"
  90:                  Runat="server" />
  91:              <br />
  92:              <asp:Button
  93:                  id="btnInsert"
  94:                  Text="Add Comment"
  95:                  CommandName="Insert"
  96:                  Runat="server" />    
  97:              </InsertItemTemplate>
  98:          </asp:ListView>
  99:          </ContentTemplate>
 100:          </asp:UpdatePanel>
 101:          <asp:SqlDataSource
 102:              id="srcMovieComments"
 103:              ConnectionString='<%$ ConnectionStrings:con %>'
 104:              SelectCommand="SELECT Id, Comment 
 105:                  FROM MovieComment
 106:                  WHERE MovieId=@MovieId"
 107:              InsertCommand="INSERT MovieComment (Comment,MovieId)
 108:                  VALUES (@Comment,@MovieId)"
 109:              Runat="server">
 110:              <SelectParameters>
 111:                  <asp:ControlParameter Name="MovieId" ControlID="ddlMovie" />
 112:              </SelectParameters>    
 113:              <InsertParameters>
 114:                  <asp:ControlParameter Name="MovieId" ControlID="ddlMovie" />
 115:              </InsertParameters>    
 116:          </asp:SqlDataSource>     
 117:          </fieldset>        
 118:          </ItemTemplate>
 119:      </asp:FormView>   
 120:      </ContentTemplate> 
 121:      </asp:UpdatePanel>
 122:      <asp:SqlDataSource
 123:          id="srcMovie"
 124:          ConnectionString='<%$ ConnectionStrings:con %>'
 125:          SelectCommand="SELECT Id, Title, Director 
 126:              FROM Movie
 127:              WHERE Id=@Id"
 128:          Runat="server">
 129:          <SelectParameters>
 130:              <asp:ControlParameter Name="Id" ControlID="ddlMovie" />
 131:          </SelectParameters>    
 132:      </asp:SqlDataSource>     
 133:      </div>
 134:      </form>
 135:  </body>
 136:  </html>

Notice that I also updated the way that the current time is displayed for this code sample. I changed:

Inner UpdatePanel Time: <%= DateTime.Now.ToString("T") %>

To:

Inner UpdatePanel Time: <%# DateTime.Now.ToString("T") %>

The correct code for Listing 31.24 is:

   1:  <%@ Page Language="C#" %>
   2:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   3:  <html xmlns="http://www.w3.org/1999/xhtml">
   4:  <head runat="server">
   5:      <title>Timer Messages</title>
   6:      <style type="text/css">
   7:      .message
   8:      {
   9:          margin-left: 20px;
  10:          font-style:italic;
  11:      }
  12:      </style>
  13:  </head>
  14:  <body>
  15:      <form id="form1" runat="server">
  16:      <asp:ScriptManager ID="sm1" runat="server" />
  17:      <asp:Timer ID="Timer1" Interval="5000" runat="server" />
  18:      <asp:UpdatePanel ID="up1" runat="server">
  19:      <Triggers>
  20:          <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
  21:      </Triggers>
  22:      <ContentTemplate>
  23:      Last Refresh <%= DateTime.Now.ToString("T") %>
  24:      <hr />
  25:      <asp:ListView
  26:          id="lstMessages"
  27:          DataSourceID="srcMessages"
  28:          Runat="server">
  29:          <LayoutTemplate>
  30:              <asp:Placeholder id="itemPlaceholder" runat="server" />
  31:          </LayoutTemplate>
  32:          <ItemTemplate>
  33:              <div>
  34:                  Posted by <%# Eval("PostedBy") %>
  35:                  <div class="message">
  36:                  <%# Eval("Post") %>
  37:                  </div>
  38:              </div>    
  39:          </ItemTemplate>
  40:      </asp:ListView>    
  41:      </ContentTemplate>      
  42:      </asp:UpdatePanel>
  43:      <asp:ObjectDataSource
  44:          id="srcMessages"
  45:          TypeName="Message"
  46:          SelectMethod="Select"
  47:          Runat="server" />
  48:      </form>
  49:  </body>
  50:  </html>

Thank you Nikolay for pointing out these errors.

If you liked this blog post then please Subscribe to this blog.
posted on Monday, March 03, 2008 7:31 PM | Filed Under [ ASP.NET Unleashed ]

Comments

Gravatar
# re: ASP.NET 3.5 Unleashed Errata: Listing 31.6 and Listing 31.24
Posted by http://
on 3/14/2008 2:27 PM

Hi Stephen,<br /><br />I have your book and found it usefull.<br />Unfortunatelly there are some errors on the book code. You're doing a great job to fixing them but It will be more usefull to publish complete fixed sources as zip somewhere here or on Superexpert site. This will allow us to get the latest version without doing merge.<br /><br />Thanks,<br />John
Gravatar
# re: ASP.NET 3.5 Unleashed Errata: Listing 31.6 and Listing 31.24
Posted by Lee
on 3/17/2008 8:23 AM

Just thought I would also comment on how much your book has helped me. Although I still haven't made the move to C# from VB.NET your book has helped me no end.. thanks
Gravatar
# re: ASP.NET 3.5 Unleashed Errata: Listing 31.6 and Listing 31.24
Posted by http://
on 4/13/2008 7:14 AM

Sir, I have found your book very useful.I am a ASP.NET/C# developer. I need ASP.NET 2.0 Shopping Cart sample application code sample. You can email me at shahid824@gmail.com
Gravatar
# re: ASP.NET 3.5 Unleashed Errata: Listing 31.6 and Listing 31.24
Posted by gao xuexian
on 1/7/2009 3:39 PM

Sir,I'm chinese reader,I have found your book very useful.I need ASP.NET 2.0 Unleashed code sample.but I can't find them at this WebSite. Please email me the code at xiaoling1569@163.com <br />or xuexian1569@gmail.com
Gravatar
# re: ASP.NET 3.5 Unleashed Errata: Listing 31.6 and Listing 31.24
Posted by wireless
on 2/6/2009 1:09 AM

Where is the code samples which in ASP.Net 3.5 unleashed book were written in both c# and visual basic.net??? i can't find in this website...
Gravatar
# re: ASP.NET 3.5 Unleashed Errata: Listing 31.6 and Listing 31.24
Posted by Manuela
on 4/24/2009 12:31 PM

Sir, Your book is very good and very well written. Thank you for it.<br />I want to ask you a question: could you please, send me the source code of the examples? <br />Thank you a lot.<br />Manuela <br />
Gravatar
# re: ASP.NET 3.5 Unleashed Errata: Listing 31.6 and Listing 31.24
Posted by Luis Josue
on 5/13/2009 9:56 AM

Where I can find the Visual Basic Example because i dont have the cd can email for me the answer josue.dpr@gmail.com
Gravatar
# re: ASP.NET 3.5 Unleashed Errata: Listing 31.6 and Listing 31.24
Posted by Mahmood
on 7/10/2009 9:57 AM

Hi,<br /><br />unfortunatly, i lost the source code CD of ASP.Net Unleashed (2nd Edition). can you help me find out from where i can find source code.<br /><br />i will really appriciate that.<br /><br />Many thanks,<br />
Comments have been closed on this topic.