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
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.
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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
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 >>
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
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
>
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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
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 >>