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 6th, 2010, 07:40 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

One is used to assign plain text, the other to assign HTML. However, innerText is not supported by all browsers. For more info:

http://www.webdeveloper.com/forum/ar...p/t-10354.html

jQuery fixes the absence of innerText with the text() method.

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 December 27th, 2011, 01:06 AM
Authorized User
 
Join Date: Dec 2011
Posts: 26
Thanks: 1
Thanked 4 Times in 3 Posts
Default trying with toggle method

Hello,
I have been trying this exercise (ch. 11 ex 1) with the .toggle method instead of the slide toggle. It causes the banner to disappear just fine, but as the earlier poster mentioned, the code for switching the link's text does not work. So, I am trying Imar's new code in this thread with the Toggle method, and it is not working. I am guessing that is likely because the toggle method works differently and can't do the callback the same way?
Side question: Where can I find some reference/reminder on what a callback is in this case?

Here is the whole banner.aspx code as I am trying it now with the main part I am working on bolded (if this forum text editor will allow it):

Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Banner.ascx.cs" Inherits="Controls_Banner" %>
<script runat="server">

</script> 
<span id="HideTest" style='cursor:pointer'>click to hide</span>
<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>

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

    <script type="text/javascript">
        $(function ()
        {
            $('#HideTest').bind('click',
                function ()
                {
                    //This commented out below is how I had it before trying the new way of getting the text change to work.
                    // $('#VerticalPanel').toggle();

/* this is the new way I have tried. The one thing I notice is that slidetoggle has .slideToggle('slow', function... and mine, of course, does not have the 'slow' part first. I guess what it comes down to is I don't understand how the callback works and, thus, don't understand how to build the syntax for it. */
                    $('#VerticalPanel').toggle(function ()
                    {
                        if ($(this).css('display') == 'block')
                        {
                            $('#HideTest').text = 'Click here to Hide Banner';
                        }
                        else
                        {
                            $('#HideTest').text = 'Show Banner';
                        }
                    });
                });
        });
    </script>
 
Old December 27th, 2011, 08:30 PM
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,

text() is a method, not a property. Does it work when you assign the text like this instead (twice):

Code:
$('#HideTest').text('Click here to Hide Banner');
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!
The Following User Says Thank You to Imar For This Useful Post:
Notso (December 28th, 2011)
 
Old December 28th, 2011, 12:30 AM
Authorized User
 
Join Date: Dec 2011
Posts: 26
Thanks: 1
Thanked 4 Times in 3 Posts
Default

Thanks, Imar. That works great.





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.