Code Comments
Programming Forum and web based access to our favorite programming groups.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.
Post Follow-up to this messageWhat 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. >
Post Follow-up to this messageThanks, 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... > >
Post Follow-up to this messagein 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... > >
Post Follow-up to this messageThank 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... > >
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.