C# HtmlGenericControl

  • Thread starter Thread starter Coder Coder
  • Start date Start date
C

Coder Coder

Hi.

I have an aspx page which has a datagrid sitting inside of DIV tags.

The users can now scroll down to look at the all the items in the
datagrid.
The only problem is that when a selection is made and the page is
reloaded the scrollbar of the DIV tag goes back up to the top. So the
user has to scroll back down again to see the previous selection.

I have tried SmartNavigation but that didnt do the trick.
I have used:

Control cont = null;
cont = Page.FindControl ("mydiv");
if (cont == null)
{
alert.Text = "control not found";
}
else
{
alert.Text = "control found";
}

mydiv = (HtmlGenericControl) cont;

This tells me that the control was FOUND so, I then do the
following:

int newLocation = DataGrid.SelectedIndex * 20;
mydiv.Attributes.Add ("scrollTop", newLocation);


However the scroll bars of the DIV dont move.

In javascript if you do the following:

var sp = document.getElementById('mydiv');
sp.scrollTop = 150;

It moves the scrolls.

But I need to do it in the code behind to see which index was
selected.

- Thanks
 
Back
Top