Objectmix
Tags Register Mark Forums Read

shouldn't the DIV remember this? : DOTNET

This is a discussion on shouldn't the DIV remember this? within the DOTNET forums in Framework and Interface Programming category; hey all, i have a div on my page where i set the ScrollLeft value. when i do a postback the div is set back to 0. i've made the DIV runat server and enabled viewstate. what would i have to do to make this work? thanks, rodchar...


Object Mix > Framework and Interface Programming > DOTNET > shouldn't the DIV remember this?

DOTNET Discussion forums related to Microsoft Dot net technologies, CSharp and other related items

Reply

 

LinkBack Thread Tools
  #1  
Old 10-13-2007, 10:14 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default shouldn't the DIV remember this?

hey all,
i have a div on my page where i set the ScrollLeft value. when i do a
postback the div is set back to 0. i've made the DIV runat server and enabled
viewstate. what would i have to do to make this work?

thanks,
rodchar
  #2  
Old 10-13-2007, 11:28 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: shouldn't the DIV remember this?

Are you setting ScrollLeft using JavaScript or during a postback? If you are
setting it using JavaScript it will not be remembered because the JavaScript
will not modify the ViewState. It may also be helpful if you showed us your
code.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"rodchar" <rodchar@discussions.microsoft.com> wrote in message
news:A102FB1B-8EF2-475A-85FE-176DD042CAB8@microsoft.com...
> hey all,
> i have a div on my page where i set the ScrollLeft value. when i do a
> postback the div is set back to 0. i've made the DIV runat server and
> enabled
> viewstate. what would i have to do to make this work?
>
> thanks,
> rodchar



  #3  
Old 10-13-2007, 02:50 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: shouldn't the DIV remember this?

yes i am setting value using javascript that's in the head section. so do i
have any options this way?

<script language="javascript" type="text/javascript">
// <!CDATA[
function scrollDiv(direction){
y=document.getElementById("OnlyDIV")
y.scrollLeft=(direction=="left")?y.scrollLeft-75:y.scrollLeft+75
c.value=y.scrollLeft;
}

<html>
....
<input id="BtnLeft" style="width: 46px; height: 24px"
type="button" value="Left"
onclick="scrollDiv('left')" />


"Nathan Sokalski" wrote:

> Are you setting ScrollLeft using JavaScript or during a postback? If you are
> setting it using JavaScript it will not be remembered because the JavaScript
> will not modify the ViewState. It may also be helpful if you showed us your
> code.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "rodchar" <rodchar@discussions.microsoft.com> wrote in message
> news:A102FB1B-8EF2-475A-85FE-176DD042CAB8@microsoft.com...
> > hey all,
> > i have a div on my page where i set the ScrollLeft value. when i do a
> > postback the div is set back to 0. i've made the DIV runat server and
> > enabled
> > viewstate. what would i have to do to make this work?
> >
> > thanks,
> > rodchar

>
>
>

  #4  
Old 10-13-2007, 03:44 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: shouldn't the DIV remember this?

There is no way to have ViewState remember values set using JavaScript, but
what you can do is create an <input type="hidden"> and set the value
property as part of the function. Then when you postback you can have
ASP.NET use that value when generating the returned page. This is usually
the best way to avoid losing values set by JavaScript. Good Luck!
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"rodchar" <rodchar@discussions.microsoft.com> wrote in message
news:6BB1F12E-7C3A-4D9E-95F2-8433D00681C0@microsoft.com...
> yes i am setting value using javascript that's in the head section. so do
> i
> have any options this way?
>
> <script language="javascript" type="text/javascript">
> // <!CDATA[
> function scrollDiv(direction){
> y=document.getElementById("OnlyDIV")
> y.scrollLeft=(direction=="left")?y.scrollLeft-75:y.scrollLeft+75
> c.value=y.scrollLeft;
> }
>
> <html>
> ...
> <input id="BtnLeft" style="width: 46px; height: 24px"
> type="button" value="Left"
> onclick="scrollDiv('left')" />
>
>
> "Nathan Sokalski" wrote:
>
>> Are you setting ScrollLeft using JavaScript or during a postback? If you
>> are
>> setting it using JavaScript it will not be remembered because the
>> JavaScript
>> will not modify the ViewState. It may also be helpful if you showed us
>> your
>> code.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>
>> "rodchar" <rodchar@discussions.microsoft.com> wrote in message
>> news:A102FB1B-8EF2-475A-85FE-176DD042CAB8@microsoft.com...
>> > hey all,
>> > i have a div on my page where i set the ScrollLeft value. when i do a
>> > postback the div is set back to 0. i've made the DIV runat server and
>> > enabled
>> > viewstate. what would i have to do to make this work?
>> >
>> > thanks,
>> > rodchar

>>
>>
>>



  #5  
Old 10-13-2007, 04:56 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: shouldn't the DIV remember this?

thank you for the help.
rod.

"Nathan Sokalski" wrote:

> There is no way to have ViewState remember values set using JavaScript, but
> what you can do is create an <input type="hidden"> and set the value
> property as part of the function. Then when you postback you can have
> ASP.NET use that value when generating the returned page. This is usually
> the best way to avoid losing values set by JavaScript. Good Luck!
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "rodchar" <rodchar@discussions.microsoft.com> wrote in message
> news:6BB1F12E-7C3A-4D9E-95F2-8433D00681C0@microsoft.com...
> > yes i am setting value using javascript that's in the head section. so do
> > i
> > have any options this way?
> >
> > <script language="javascript" type="text/javascript">
> > // <!CDATA[
> > function scrollDiv(direction){
> > y=document.getElementById("OnlyDIV")
> > y.scrollLeft=(direction=="left")?y.scrollLeft-75:y.scrollLeft+75
> > c.value=y.scrollLeft;
> > }
> >
> > <html>
> > ...
> > <input id="BtnLeft" style="width: 46px; height: 24px"
> > type="button" value="Left"
> > onclick="scrollDiv('left')" />
> >
> >
> > "Nathan Sokalski" wrote:
> >
> >> Are you setting ScrollLeft using JavaScript or during a postback? If you
> >> are
> >> setting it using JavaScript it will not be remembered because the
> >> JavaScript
> >> will not modify the ViewState. It may also be helpful if you showed us
> >> your
> >> code.
> >> --
> >> Nathan Sokalski
> >> njsokalski@hotmail.com
> >> http://www.nathansokalski.com/
> >>
> >> "rodchar" <rodchar@discussions.microsoft.com> wrote in message
> >> news:A102FB1B-8EF2-475A-85FE-176DD042CAB8@microsoft.com...
> >> > hey all,
> >> > i have a div on my page where i set the ScrollLeft value. when i do a
> >> > postback the div is set back to 0. i've made the DIV runat server and
> >> > enabled
> >> > viewstate. what would i have to do to make this work?
> >> >
> >> > thanks,
> >> > rodchar
> >>
> >>
> >>

>
>
>

Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
Trying to remember .... usenet Scheme 2 05-02-2007 04:58 AM
Anyone remember an ado.net cheatsheet on the web? usenet ADO DAO RDO RDS 0 03-19-2007 01:02 PM
i remember... usenet awk 2 12-14-2006 10:20 AM
Something to remember usenet ADO DAO RDO RDS 0 03-08-2006 11:57 AM
OWA Does not Remember PAssword usenet Microsoft Exchange 0 08-27-2004 10:50 AM


All times are GMT -5. The time now is 08:32 AM.

Managed by Infnx Pvt Ltd.