Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Problem setting InnerText value
I hope this illustrates my question a little better. Consider the following
script; why does the client side script change the div object's innerHtml
property but the server side script does not? Debug reports that the server
script does not see the document's div object but I thought I read that
varibles created with page scope are available throughout the page.


<%@ language="VBSCRIPT" %>
<html>
<head>
<script language="vbscript">
Sub chgDivText
oDiv1.InnerHtml="Div changed by button"
End sub
</script>
</head>
<body>
<div id="oDiv1">Div Label</div>
<button onclick="chgdivtext">"Change Div Text"</button>
</body>
<%
oDiv1.InnerHtml="Div changed by server"
%>
</html>

Thanks for your help.



Report this thread to moderator Post Follow-up to this message
Old Post
scott cooper
03-30-05 08:57 AM


Re: Problem setting InnerText value
What you read was correct, but what you're missing is that the script there
runs at two different times. The server-side script runs before the page is
ever delivered to the browser, so doesn't have access to client-side data.
An ASP variable is accessible throughout the page, but any client-side
objects or variables (such as DOM references) are most definitely not
available.



--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no rights.

"scott cooper" <scott.cooper@charter.net> wrote in message
news:u1Wv%23JNNFHA.1096@tk2msftngp13.phx.gbl...
>I hope this illustrates my question a little better. Consider the following
>script; why does the client side script change the div object's innerHtml
>property but the server side script does not? Debug reports that the server
>script does not see the document's div object but I thought I read that
>varibles created with page scope are available throughout the page.
>
>
> <%@ language="VBSCRIPT" %>
> <html>
> <head>
> <script language="vbscript">
> Sub chgDivText
> oDiv1.InnerHtml="Div changed by button"
> End sub
> </script>
> </head>
> <body>
> <div id="oDiv1">Div Label</div>
> <button onclick="chgdivtext">"Change Div Text"</button>
> </body>
> <%
> oDiv1.InnerHtml="Div changed by server"
> %>
> </html>
>
> Thanks for your help.
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jason Brown [MSFT]
03-30-05 08:57 AM


Re: Problem setting InnerText value
Thanks, I kind of thought that was the case but I dont understand why an
object I created in the server script could not be used by a client side
script and returned the object required error when I tried read one of the
object's properties.

"Jason Brown [MSFT]" <i-brjaso@online.microsoft.com> wrote in message
news:emwGVTNNFHA.2464@TK2MSFTNGP10.phx.gbl...
> What you read was correct, but what you're missing is that the script
> there runs at two different times. The server-side script runs before the
> page is ever delivered to the browser, so doesn't have access to
> client-side data. An ASP variable is accessible throughout the page, but
> any client-side objects or variables (such as DOM references) are most
> definitely not available.
>
>
>
> --
> Jason Brown
> Microsoft GTSC, IIS
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "scott cooper" <scott.cooper@charter.net> wrote in message
> news:u1Wv%23JNNFHA.1096@tk2msftngp13.phx.gbl... 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
scott cooper
03-30-05 08:57 AM


Re: Problem setting InnerText value
in ASP, client and server are two separate environments and should be
treated as such. ASP.NET tries to blur the boundary somewhat, with
server-side objects and events which can either smotth things or complicate
things depending on your level of understanding.


--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.


"scott cooper" <scott.cooper@charter.net> wrote in message
news:u01k6XNNFHA.1308@TK2MSFTNGP15.phx.gbl...
> Thanks, I kind of thought that was the case but I dont understand why an
> object I created in the server script could not be used by a client side
> script and returned the object required error when I tried read one of the
> object's properties.
>
> "Jason Brown [MSFT]" <i-brjaso@online.microsoft.com> wrote in message
> news:emwGVTNNFHA.2464@TK2MSFTNGP10.phx.gbl... 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jason Brown [MSFT]
03-30-05 08:57 AM


Re: Problem setting InnerText value
Thank you Jason. It seemed to me that I should be able to referance
variables and objects created by a server script but your words make sense
to me. I guess it might have been wishful coding. :-)

"Jason Brown [MSFT]" <i-brjaso@online.microsoft.com> wrote in message
news:e3HRdhNNFHA.3704@TK2MSFTNGP12.phx.gbl...
> in ASP, client and server are two separate environments and should be
> treated as such. ASP.NET tries to blur the boundary somewhat, with
> server-side objects and events which can either smotth things or
> complicate things depending on your level of understanding.
>
>
> --
> Jason Brown
> Microsoft GTSC, IIS
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> "scott cooper" <scott.cooper@charter.net> wrote in message
> news:u01k6XNNFHA.1308@TK2MSFTNGP15.phx.gbl... 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
scott cooper
03-30-05 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

ASP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:00 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.