Wrox Programmer Forums
|
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 September 4th, 2010, 06:38 PM
Authorized User
 
Join Date: Sep 2010
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Default chapter 11 exercise 1(page401)

hello all. i have a problem with exersice 1 of chapter 11. i copy the code from the appendix A with solutions of exercises (p.743). i wrote the code at Banner.ascx in markup view. the code is:


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Banner.ascx.cs" Inherits="Controls_Banner" %>
<asp:Panel ID="VerticalPanel" runat="server" ClientIDMode="Static">

<a href="http://p2p.wrox.com" target="_blank" runat="server" id="VerticalLink">
<asp:Image ID="Image1" runat="server" AlternateText="This is a sample banner"
ImageUrl="~/Images/Banner120x240.gif" />
</a>
</asp:Panel>
<span id="HideBanner" runat="server" style="cursor:pointer;" clientidmode="Static">Hide Banner</span>
<script type="text/javascript">
$(function () {
$('#HideBanner').bind('click', function () {
$('#VerticalPanel').slideToggle();
if ($(this).css('display') == 'block') {
$('#HideBanner')[0].innerText = 'Hide Banner';
}
else {
$('#HideBanner')[0].innerText = 'Show Banner';
}
});
});
</script>
<asp:Panel ID="HorizontalPanel" runat="server">
<a href="http://p2p.wrox.com" target="_blank" runat="server" id="HorizontalLink">
<asp:Image ID="Image2" runat="server" AlternateText="This is a sample banner"
ImageUrl="~/Images/Banner468x60.gif" />
</a>
</asp:Panel>


---------------------------------------------------------------

the problem is that the text of the HideBanner don't change when the banner is hidden to 'Show Banner', or not hidden to 'Hide Banner'. whats the wrong? i have vwd 2010, aspnet4,firefox 2.6.8,win xp

thanks!

Last edited by stram; September 4th, 2010 at 06:53 PM..
 
Old September 4th, 2010, 11:08 PM
Authorized User
 
Join Date: Aug 2010
Posts: 10
Thanks: 0
Thanked 1 Time in 1 Post
Default

$(function () {


Is the ( supposed to be there before the function? It doesn't look like it belongs there, otherwise it does not look as thought it's being closed.
 
Old September 5th, 2010, 04:36 AM
Authorized User
 
Join Date: Sep 2010
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Default

the ( before the function is right. it closed at the end of the code with the });
 
Old September 5th, 2010, 05:33 AM
Registered User
 
Join Date: Sep 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newbie

Hi there I am a newbie to this forum. Just bought "Beginning php5.3". I on chapter 14 but have issue with my database connection.

here is the code
database.php

<?php
define( "DB_DSN", "mysql:dbname=db_members" );
define( "DB_USERNAME", "username" );
define( "DB_PASSWORD", "pass" );
define( "PAGE_SIZE", 5 );
define( "TBL_MEMBERS", "members" );
define( "TBL_ACCESS_LOG", "accessLog" );
?>

this is what I receive as a warning
when I warn to connect on the server e.g. login.
Query failed: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_members.members' doesn't exist


Can someone help please!!
 
Old September 6th, 2010, 03:36 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 stram,

Not sure what changed, but the code doesn't work for me anymore either. I am still trying to find out if something has changed in jQuery, or the code never worked correctly. The problem is that slideToggle hasn't run completely by the time the code checks the CSS display setting. As such, it hasn't changed yet, and the text will never be changed. The fix is easy; instead of adding the lines that change the innerText as a separate block below the slideToggle call, you can specify that code as a callback argument to slideToggle. jQuery will execute that code when the slideToggle is finished which is exactly the right moment to carry out the check for the display setting. Something like this should work:

Code:
$(function ()
{
  $('#HideBanner').bind('click', function ()
  {
    $('#VerticalPanel').slideToggle('fast', function ()
    {
      if ($(this).css('display') == 'block')
      {
        $('#HideBanner')[0].innerText = 'Hide Banner';
      }
      else
      {
        $('#HideBanner')[0].innerText = 'Show Banner';
      }
    });
  });
});
Notice how the code is now wrapped in function () { ... } so it's called when slideToggle is done.

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 September 6th, 2010, 03:48 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 lokang,

Looks like you posted this in the wrong forum, as this forum is related to the book Beginning ASP.NET 4. Try finding your book's forum on the main forum list: http://p2p.wrox.com/

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 September 6th, 2010, 03:49 AM
Registered User
 
Join Date: Sep 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default thanks

thanks for your help
 
Old September 6th, 2010, 06:43 AM
Authorized User
 
Join Date: Sep 2010
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Default

hello Imar and thanks for your help... i tried your new code but it doesn't work. the text don't change.

all code:


Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Banner.ascx.cs" Inherits="Controls_Banner" %>
<asp:Panel ID="VerticalPanel" runat="server" ClientIDMode="Static">

    <a href="http://p2p.wrox.com" target="_blank" runat="server" id="VerticalLink">
    <asp:Image ID="Image1"  runat="server" AlternateText="This is a sample banner" 
        ImageUrl="~/Images/Banner120x240.gif" />
        </a>
</asp:Panel>
<span id="HideBanner" runat="server" style="cursor:pointer;" clientidmode="Static">Hide Banner</span>
<script type="text/javascript">
    $(function () {
        $('#HideBanner').bind('click', function () {
            $('#VerticalPanel').slideToggle('fast', function () {
                if ($(this).css('display') == 'block') {
                    $('#HideBanner')[0].innerText = 'Hide Banner';
                }
                else {
                    $('#HideBanner')[0].innerText = 'Show Banner';
                }
            });
        });
    });
</script>
<asp:Panel ID="HorizontalPanel" runat="server">
    <a href="http://p2p.wrox.com" target="_blank" runat="server" id="HorizontalLink">
    <asp:Image ID="Image2"  runat="server" AlternateText="This is a sample banner" 
        ImageUrl="~/Images/Banner468x60.gif" />
        </a>
</asp:Panel>
 
Old September 6th, 2010, 06:55 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

On which browser do you test this? Maybe it doesn't support innerText? You can change it to this instead:

Code:
 
if ($(this).css('display') == 'block')
{
 $('#HideBanner')[0].innerHTML = 'Hide Banner';
}
else
{
 $('#HideBanner')[0].innerHTML = 'Show Banner';
}
or more jQuery like:

Code:
 
if ($(this).css('display') == 'block')
{
 $('#HideBanner').text('Hide Banner');
}
else
{
 $('#HideBanner').text('Show Banner');
}
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 September 6th, 2010, 07:36 AM
Authorized User
 
Join Date: Sep 2010
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Default

i'm using firefox 3.6.8.

ok with inerHTML it works

whats the different between innerText and innerHTML ?

thanks again!





Similar Threads
Thread Thread Starter Forum Replies Last Post
JQuery Troubles- Chapter 11, Exercise 1 Princess Rose BOOK: Beginning ASP.NET 4 : in C# and VB 6 May 3rd, 2010 05:35 PM
chapter 11 figure 11-7 relative positioning pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 November 29th, 2007 06:11 AM
Ch 11 Pg459 Exercise 5 C# brivad BOOK: Beginning ASP.NET 1.0 0 September 10th, 2007 08:59 AM
Chapter 11 Exercise - IE6 Margins discgolfer BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 4 January 23rd, 2006 01:05 PM





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