Wrox Programmer Forums
|
BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4
This is the forum to discuss the Wrox book Beginning Dreamweaver MX by Charles E. Brown, Imar Spaanjaars, Todd Marks; ISBN: 9780764544040
Please indicate which version of the book you are using when posting questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4 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 April 7th, 2004, 04:55 AM
Authorized User
 
Join Date: Sep 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dreamweaver MX - change background color

Hi Imar!

As a practice, I have written a simple program (based on your try it out in chapter 11) where there is a form with just 2 inputs. One is a text field and the other is a submit button. When I type the color in the textbox and click the button, the web page should change its own background-color according to the color given the textbox of the form. However when I open the page in the browser following happens:

1. For the first time when I open the page in the browser and type the color (e.g. #CCCCCC) in the textbox, nothing happens – the page remains white.
2. The second time when I type the color and click the button, the following error message is displayed:

--------------------------------------------------------------------------------------------------------------------------------
Response object error 'ASP 0156 : 80004005'
Header Error
/cookietrial/changeColor.asp, line 4
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content
----------------------------------------------------------

I have pasted the code below. Could you please tell me what is wrong with it?

----------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
    If Request.Form("btnColor") <> "" Then
        Response.Cookies("BackGroundColor") = Request.Form("txtColor")
        Response.Cookies("BackGroundColor").Expires = Date() + 30
    End If
    Dim sBackgroundColor
    If Len(Request.Cookies("BackGroundColor")) > 0 Then
        sBackgroundColor = Request.Cookies("BackGroundColor")
    Else
        sBackgroundColor = "#FFFFFF"
    End If

%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body style="background-color: <%= sBackgroundColor %>" >
<form action="changeColor.asp" method="post" name="frmColor"><input name="txtColor" type="text" value="">
  <input name="btnColor" type="submit" value="Change Background Color"></form>
</body>
</html>
------------------------------------------------------

Thanks.

Shubhada


 
Old April 7th, 2004, 05:07 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I knew that would happen.... ;)


Check out page 310, under the heading "Forewarned is Forearmed"...

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 7th, 2004, 06:20 AM
Authorized User
 
Join Date: Sep 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar!

Thanks. I shuffled the code around and it is working now.

But why should it so happen when all I was doing was setting the value of the variable ‘sBackgroundColor’ before writing the cookie? I was not outputting any content to the browser before writing the cookie.

Shubhada.


 
Old April 7th, 2004, 06:28 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Are you use you didn't sent any content to the browser? Even spaces and tabs can cause this problem.

I copied and pasted your code to a PWS installation on Windows ME (I finally got to setting it up under Virtual PC) and it ran fine immediately....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 7th, 2004, 06:29 AM
Authorized User
 
Join Date: Sep 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey...wait..wait!!
I did shuffle the code - but shuffled it 2-3 times. And finally when it is working, the statements are in exactly in the same order as before.

<%
    If Request.Form("btnColor") <> "" Then
        Response.Cookies("BackGroundColor") = Request.Form("txtColor")
        Response.Cookies("BackGroundColor").Expires = Date() + 30
    End If
    Dim sBackgroundColor
    If Len(Request.Cookies("BackGroundColor")) > 0 Then
        sBackgroundColor = Request.Cookies("BackGroundColor")
    Else
        sBackgroundColor = "#FFFFFF"
    End If

%>
And now it is working. The same order of statements was not working before. Effectively, nothing is changed, then why so?

Shubhada.

 
Old April 7th, 2004, 06:32 AM
Authorized User
 
Join Date: Sep 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Our responses crossed.

Yes, may be some tab or space was inserted in the previous code, which was removed while shuffling - so now it is working.

Were you able to reproduce my previous error (uppercase variables) on ME+PWS?

Shubhada.


 
Old April 7th, 2004, 06:35 AM
Authorized User
 
Join Date: Sep 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I checked both the codes. There was no tab or space in my previous code. I also did not send any other content to the browser. Still it was not working.

Shubhada.



 
Old April 7th, 2004, 06:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Not yet. I *just* got it working. In fact, I just finished the install procedure after I received this post, so I could take a look and see if it was a PWS issue.

The install procedure didn't go so easy. The downloader file for PWS is no longer able to download the correct files automatically, so it took me a while to figure out what to do.

I'll try the app var issue later today, hopefully.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 7th, 2004, 06:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Right. I was just able to reproduce the UCase issue. I set a few Session and App vars, and this is what I got when I ran the test page that dumps the Session and Application variables:

STARTTIME : 4/7/2004 1:43:55 PM
TEST : Test Value
List of 2 items in Application contents collection:
-----------------------------------------------------------
TOTALNUMBEROFUSERS : 1
CURRENTNUMBEROFUSERS : 1

So, also on my PWS installation, the names of the vars are uppercased. I still haven't found out whether this is a known issue or not, but it sure is something to remember.....

Does the cookie code still work?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 7th, 2004, 07:26 AM
Authorized User
 
Join Date: Sep 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, the cookie code is still working.

Shubhada.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Change background color using CSS pigtail Javascript How-To 9 April 4th, 2010 11:13 AM
change color of background meena88 C# 2005 3 December 1st, 2009 04:48 AM
change background color of inputbox vickriz Javascript How-To 3 December 1st, 2009 02:22 AM
change background color of toolbar control myth12345 VB How-To 1 January 6th, 2005 12:25 AM
Change the background color of a msgbox nobreferreira VB.NET 2002/2003 Basics 3 October 28th, 2004 09:37 AM





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