Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Problem setting InnerText value

Reply
Thread Tools

Problem setting InnerText value

 
 
scott cooper
Guest
Posts: n/a
 
      03-30-2005
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.


 
Reply With Quote
 
 
 
 
Jason Brown [MSFT]
Guest
Posts: n/a
 
      03-30-2005
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" <(E-Mail Removed)> wrote in message
news:u1Wv%(E-Mail Removed)...
>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.
>



 
Reply With Quote
 
 
 
 
scott cooper
Guest
Posts: n/a
 
      03-30-2005
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:u1Wv%(E-Mail Removed)...
>>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.
>>

>
>



 
Reply With Quote
 
Jason Brown [MSFT]
Guest
Posts: n/a
 
      03-30-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:u1Wv%(E-Mail Removed)...
>>>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.
>>>

>>
>>

>
>



 
Reply With Quote
 
scott cooper
Guest
Posts: n/a
 
      03-30-2005
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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" <(E-Mail Removed)> wrote in message
>>> news:u1Wv%(E-Mail Removed)...
>>>>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.
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with innerText/textContent Srinivasa Javascript 2 02-14-2007 12:47 PM
Write Panel's innerText dw ASP .Net 4 09-06-2004 02:14 PM
innerText of xml doc martin ASP .Net 6 03-06-2004 11:34 PM
force line break inside .InnerText John A Grandy ASP .Net 3 10-17-2003 02:01 AM
Setting the innerText / innerHTML on a <span> Kerri ASP General 4 09-28-2003 03:04 PM



Advertisments