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

Display Html page in RadHtmlPlaceholder

7 Answers 135 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
Mahendra
Top achievements
Rank 1
Mahendra asked on 16 Sep 2011, 06:50 AM
Hello,

 In Silverlight4 i want to read html page using RadHtmlPlaceholder. my xaml page is in one application and i have created another Silvelright Class Library project named MyHtmlPagePrj. There is html page TestHtml.htm. I made it as Resource from Right Clik-> Properties

Now I want to access this page in my Silverlight Xaml project.
I can do that by renaming htm to txt file like TestHtml.txt and write the code below

StreamReader streamReader = new StreamReader(Application.GetResourceStream(new Uri("/MyHtmlPagePrj;component/TestHtml.txt", UriKind.RelativeOrAbsolute)).Stream);

 

htmlPlaceholderCompanyWeb.HtmlSource = streamReader.ReadToEnd();


Now i am able to see Html page in Silverlight.

But I want to read html directly instead of txt file. I tried as below

Uri

 

 

uri = new Uri("/MyHtmlPagePrj;component/TestHtml.htm",UriKind.Relative);

 

htmlPlaceholderCompanyWeb.SourceUrl = uri;


But it doesnt display page. Please give me solution how i can get html page in that.

Thanks,
Mahendra

 

7 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 21 Sep 2011, 03:31 PM
Hi Mahendra,

 The RadHtmlPlaceHolder needs a WebProject and when you want to pass it a .htm file , you need to place the file in the ClienBin folder of the WebProject. You cannot access a local file (Silverlight Framework restriction) unless you are in OOB mode.
The other approach you can use is to use the HTMLSource property, you can examine how to use it in this help article.
Hope this is useful for  you.

Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mahendra
Top achievements
Rank 1
answered on 22 Sep 2011, 12:38 PM

Hello,

 Thanks for reply.

The example you suggested already I implemented that. Its showing me all text properly just there is issue with local image files.
Anyhow  i keep it as public and its dispalying now.

Now one more thing I want to do. In my Html page there is Javascript function and Input Button. On that button I hide perticular row(<tr>)
It works fine When i browse html page. But when I display it in Silverlight in RadHtmlPlaceholder then this function is not working.

My html page code is as below

 

 

<script language="javascript" type="text/javascript">

  function toggle() {

 if (document.getElementById("hidethis").style.display == 'none') {

 document.getElementById("hidethis").style.display = ''; }

 else {

 document.getElementById("hidethis").style.display = 'none';

 }

</script>

 <body>

 <table border="1">

 <tr> <td> Always visible</td></tr>

 <tr id="hidethis"> <td> Hide this</td> </tr>

  <tr><td> Always visible</td> </tr>

 <tr> <td> <input type="button" value="Click" runat="server" onclick="toggle();" />

  </td> </tr>

</table>

</body>

 

 

I write code in xaml page to display html page as below

streamReader = new StreamReader(Application.GetResourceStream(new Uri(strHtmlPagePath + "Test.htm", UriKind.Relative)).Stream);

 string html = streamReader.ReadToEnd();

 htmlPlaceholderCompanyWeb.HtmlSource = html;

 

By this code I am able to see Html page in Placeholder control but when I click to button in html its not working.

Please give me solution for that.


Thanks,
Mahendra

0
Petar Mladenov
Telerik team
answered on 27 Sep 2011, 12:11 PM
Hello Mahendra,

 Please check out this post describing how to call javascript function from RadHtmlPlaceHolder and let us know if it helps you. Feel free to ask if you need more info.

Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mahendra
Top achievements
Rank 1
answered on 28 Sep 2011, 07:21 AM
Hello,

 This is not my requirement. Here you have button in xaml page.

 In my case I have say 3 html pages ParentHtmlPage.html, DetailsHtmlPage1.html and DetailsHtmlPage2.html. I have 2 hyperlink  in ParentHtmlPage.html and from there i am going to open DetailsHtmlPage1.html and DetailsHtmlPage2.html.

But I am displaying ParentHtmlPage.html in RadHtmlPlaceHolder by HtmlSource. But I am unable to open those details pages from that link. If i could get event of Parenthtmp pages hyperlink in xaml then i can replace HtmlSource by new page.

So please give solution on that.

Thanks,
Mahendra
0
Petar Mladenov
Telerik team
answered on 30 Sep 2011, 02:59 PM
Hi Mahendra,

 Supposing you read the following html and load it into the HTMLSource property of the RadHtmlPlaceHolder:

<html>
    <head>
        <title></title>
    </head>
    <body>
            AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
            <a href="http://localhost:39592/html2.htm">
            Get Second
            </a>
    </body>
</html>
You can see that the hyperlink uses the real Url of the child .htm page which have to placed in the Web Project. Please examine the attached solution and let us know if it helps you. Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mahendra
Top achievements
Rank 1
answered on 30 Sep 2011, 03:58 PM
Hi,

  The example you give has html2.htm page in web project. In my case i have that page in silverlight project. Means in silverlight project i have 2 html pages HTMLPage1.htm and html2.htm. When click on link of first page i want to show html2.htm  at that place (not in new window). Simply want to replace page1 and display page 2 in radhtml holder.

Thanks,
Mahendra
0
Petar Mladenov
Telerik team
answered on 05 Oct 2011, 02:36 PM
Hi Mahendra,

 I'm afraid this cannot be implemented in the way you want. The big issue is how to access the HTMLPlaceholder when you are in the HTML page inside the HTMLPlaceholder. You can check out this msdn article and see if it can be useful for your requirement.

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
HTMLPlaceHolder
Asked by
Mahendra
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Mahendra
Top achievements
Rank 1
Share this question
or