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

Web Browser in Rotator?

4 Answers 116 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Richard Thurgood
Top achievements
Rank 1
Richard Thurgood asked on 16 Jul 2008, 12:17 PM
Hi guys,
I'd like to dynamically create and load a web browser control in the rotator.  The web browser control will be used to show either a PDF or an image depending on the data I have stored. 

foreach(DataRow dr in MyTable.Rows)
{
    //todo: create browser control

    if (IsPDF)
   {
        //todo: load PDF (from field in datarow) into browser control
    }
    else
    {
        //todo: load IMAGE (from field in datarow) into browser control
    }

    //todo: load browser control into radRotator
}

4 Answers, 1 is accepted

Sort by
0
Richard Thurgood
Top achievements
Rank 1
answered on 16 Jul 2008, 02:48 PM

Okay, perhaps I was premature in asking. The answer is "YES", you can add a browser control to a radRotator.

I whipped up something real quick to illustrate......

private void PopulateBrowserControl()
{
 for (int i = 1; i < 10; i++)
 {
  WebBrowser browser = new WebBrowser();
  browser.Navigate("about:blank");
  while (browser.ReadyState != WebBrowserReadyState.Complete)
  {
   Application.DoEvents();
  }
  browser.Document.Body.InnerHtml = "Page " + Convert.ToString(i);
  PopulateRotator(browser);
 }
 radRotator1.Goto(0);
}

private void PopulateRotator(WebBrowser browser)
{
 radRotator1.Items.Add(new RadHostItem(browser));
}

 

0
Mike
Telerik team
answered on 17 Jul 2008, 10:59 AM
Hi Richard,

It is great you found out the solution alone. Allow me one addition, though. You can also use the specialized RadWebBrowserElement, which inherits RadHostItem and wraps up the WebBrowser control for you. The advantages consist in the ability to add this item in RadRotator, RadCarousel and other controls using the Visual Studio designer.

Don't hesitate to contact us if you have further questions.

Sincerely yours,
Mike
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Richard Thurgood
Top achievements
Rank 1
answered on 17 Jul 2008, 12:15 PM
That's awesome. Can you retro-fit my example to show how to use it?
0
Nikolay
Telerik team
answered on 17 Jul 2008, 02:30 PM
Hi Richard,

As Mike said, the only advantage you will get by using RadWebBrowserElement is that you can add it at design-time in the RadRotator's Items collection, using the Visual Studio designer. However, since you are using the programmatic approach, which is good enough in this case, you do not need the RadWebBrowserElement.

If you have additional questions, feel free to contact me.

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Rotator
Asked by
Richard Thurgood
Top achievements
Rank 1
Answers by
Richard Thurgood
Top achievements
Rank 1
Mike
Telerik team
Nikolay
Telerik team
Share this question
or