This is a migrated thread and some comments may be shown as answers.

Scroll to bottom of HTMLPlaceHolder

2 Answers 78 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
Ólafur Gíslason
Top achievements
Rank 1
Ólafur Gíslason asked on 23 Apr 2010, 03:23 PM
Hi, is it possible to scroll to the bottom of a HTMLPlaceHolder in code?

I am adding to the HTMLSource and the HTMLPlaceHolder  always scrolls to the top?

Before I tried to place the HTMLPlaceHolder   within a ScrollViewer but then it is impossible to get rid of the HTMLPlaceHolder Scrollbars.  I will get a double set of scrollbars.  It is no problem to scroll to the bottom of the ScrollViewer.

I tried unsuccessfully to wire this up in the Page_Load event to get rid of the HTMLPlaceHolder scrollbar 

 (radHtmlPlaceholder1.HtmlPresenter.Children[0] as HtmlElement).SetAttribute("scrolling", "no");

regards,
Olafur


2 Answers, 1 is accepted

Sort by
0
Ólafur Gíslason
Top achievements
Rank 1
answered on 24 Apr 2010, 10:49 AM
Well, it seems there is a simple solution.

I went through all the posts here on this Forum  and used my trusted source Google.

I host the Html Placeholder in a ScrollView.

       <ScrollViewer Height="122" HorizontalAlignment="Left" Margin="41,66,0,0" 
            Name="scrollStoryboard"     VerticalAlignment="Top"         Width="514">
            <telerik:RadHtmlPlaceholder Name="radHtmlStoryboard" />
        </ScrollViewer>

Then on OnNavigatedTo event of my page I do a quick hide and show on the Placeholder and set the scolling and overflow properties.  I should be able to set these properties on the OnLoad event but it does not work.

            radHtmlStoryboard.Visibility = System.Windows.Visibility.Collapsed;
            radHtmlStoryboard.Visibility = System.Windows.Visibility.Visible;
            (radHtmlStoryboard.HtmlPresenter.Children[0] as HtmlElement).SetAttribute("scrolling", "no");
            (radHtmlStoryboard.HtmlPresenter.Children[0] as HtmlElement).SetAttribute("overflow", "visible");

And whenever I write something to the HtmlSource, I call the UpdateLayout followed by the ScrollToVerticalOffset on the ScrollView

                    htmlText = transcript .MessageText  + "<br/>";
                    radHtmlStoryboard.HtmlSource += htmlText;

                    radHtmlStoryboard.UpdateLayout();
                    scrollStoryboard.ScrollToVerticalOffset(radHtmlStoryboard.ActualHeight);
  

This works like a charm and scrolls to the bottom every time. The overflow property is needed if the output is too wide for the HtmlPlaceholder and forces a wrap on the HtmlPlaceholder and then a vertical scrollbar would appear.

regards,
Olafur

0
Kiril Stanoev
Telerik team
answered on 28 Apr 2010, 12:55 PM
Hello Ólafur,

Thank you for sharing this workaround.

Best wishes,
Kiril Stanoev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
HTMLPlaceHolder
Asked by
Ólafur Gíslason
Top achievements
Rank 1
Answers by
Ólafur Gíslason
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Share this question
or