For Programmers: Free Programming Magazines  


Home > Archive > ASP > March 2005 > Problem setting InnerText value









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem setting InnerText value
scott cooper

2005-03-30, 3:57 am

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.


Jason Brown [MSFT]

2005-03-30, 3:57 am

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



scott cooper

2005-03-30, 3:57 am

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



Jason Brown [MSFT]

2005-03-30, 3:57 am

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



scott cooper

2005-03-30, 3:57 am

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



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com