Skip to main content

Microsoft Silverlight

Answered Question Loading a HTML PageRSS Feed

(0)

Arun Solomon
Arun Sol...

Member

Member

39 points

36 Posts

Loading a HTML Page

Hi,

I'm working on SL2. How do i load/open a html page from SL, page needs to open in the same browser window. I want to write the action on a rectangle graphic, what are the options & what is the syntax to trigger this action.

Any help is really appreciated.
 

Arun

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: Loading a HTML Page

1) you can use HyperlinkButton:

<HyperlinkButton Content="SomeText" NavigateUri="somepage.html"></HyperlinkButton> 

<HyperlinkButton Content="SomeText" NavigateUri="somepage.html" TargetName="_blank"></HyperlinkButton>  // will open in a new window or tab

 

2) In the code:

HtmlPage.Window.Navigate(new Uri(newpageurl)); 

HtmlPage.Window.Navigate(new Uri(newpageurl), "_blank");  // will open in a new window or tab


 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP

Re: Loading a HTML Page

Arun Solomon:
I want to write the action on a rectangle graphic, what are the options & what is the syntax to trigger this action.
 

Yes. you can write HtmlPage.Navigate() in the MouseRightButtonDown or up event of Rectangle.  

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


Arun Solomon
Arun Sol...

Member

Member

39 points

36 Posts

Re: Loading a HTML Page

 Hi, Thanks for the help.

The command is working for a web url, i want to call an html file in my project, i am not able to call/load a html file in my project.

Do have you know how to call/load an html file inside a project.
 

Arun

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP
Answered Question

Re: Loading a HTML Page

 You need to put HTML file in ASP.NET project. 

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


Leonid Andruhin
Leonid A...

Member

Member

632 points

135 Posts

Answered Question

Re: Loading a HTML Page

May be something like this (e.Result is a text of your HtmlPage):

HtmlElement DS = HtmlPage.Document.CreateElement("input");

DS.Id = "PrintPage";

DS.SetProperty("value", e.Result);

DS.SetProperty("type", "hidden");

HtmlPage.Document.Body.AppendChild(DS);

try

{

StringBuilder sb = new StringBuilder();

sb.Append("function ShowPrintWindow(){");

sb.Append("myWin = open(\"\", \"displayWindow\", \"width=800,height=600,menubar=yes,scrollbars=yes\");");

sb.Append("myWin.document.open();");

sb.Append("myWin.document.write(document.getElementById(\"PrintPage\").value);");

sb.Append("myWin.document.close();");

sb.Append("}");

sb.Append("ShowPrintWindow();");

string sCommand = sb.ToString();HtmlPage.Window.Eval(sCommand);

}

catch (Exception any)

{

HtmlPage.Window.Alert(any.ToString());

}

finally

{

HtmlPage.Document.Body.RemoveChild(DS);

}

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities