Hi everyone, i really need a way to scroll down an HTMLPANEL with a lot of content programatically, it can be with javascript, how can i do this?
I tried this but doesnt work at all:
var scrollableElement = document.getElementById(“scrollableElement”);
scrollableElement.scrollTop = scrollableElement.scrollHeight;
The quick answer is that you should try:
var scrollableElement = document.getElementById('scrollableElement');
scrollableElement.scrollIntoView();
In more detail:
1.Create a html file. Make sure that an element within it has the id set to “scrollableElement”. (or whatever id you want to use, doesn’t matter really)
2. In the Wisej designer, create a HtmlPanel from the toolbox. Set the HtmlSource to your HTML file.
3. In the Wisej designer, create a button from the toolbox. Add a Click event.
4. In the code for the Wisej page, you should have this:
public Page1()
{
InitializeComponent();
//When the htmlPanel is initialized, create a javascript function named Scroll.
htmlPanel1.InitScript = @"this.Scroll = function() {
var scrollableElement = document.getElementById('scrollableElement');
scrollableElement.scrollIntoView(); }";
}
private void button1_Click(object sender, EventArgs e)
{
//call the Scroll function
htmlPanel1.Call("Scroll");
}
The htmlPanel will scroll when the button is clicked.
I’ve attached a sample. Hope this helps!
Please login first to submit.