In Silverlight how can I launch / navigate to another page?
System.Windows.Browser.HtmlPage.Window.Navigate(
new Uri( "http://www.google.com" ),
"_blank"
);
You can leave out the target ("_blank") if you just want to navigate within your current browser window.
To navigate to another page in from another page.
Frame frame =this.parent as Frame;
frame.navigate(new Uri("/Views/Details.xaml"),Uri.Relative);
Note, you must have a frame already in the MainPage.xaml.
So other pages are just calling the frame in the parent
Assume You are editing code behind file of Page class
this.NavigationService.Navigate(new Uri("/OtherPage.xaml", UriKind.Relative));
To avoid issues with popups being blocked when you use _blank, ensure you call Navigate from the click event of a HyperlinkButton control, as described here:
http://www.tjsblog.net/2010/10/20/opening-a-new-chrome-page-in-silverlight/
You all can also try this
this.content=new (place the page name which You want to navigate);
but this code only works while navigate page having in same folder else You have to write like in given below manner
this.Content = new Views.(place the page name which You want to navigate);
here in place of Views write the folder name where the page having...
Hope it's also helpful for you all.
Related
I have created one button. I want to redirect to another page by clicking on it in backbone. How can i do that?
I tried following code but it does not work:
router.navigate("/file:///code/order/table.html",true);
Using JavaScript:
window.location.href = 'file:///code/order/table.html';
But I would suggest to use relative path and simple anchor tag:
Table
the backbone router usage is wrong here. from the doc router.navigate(fragment, [options]) this is the function usage, the 1st argument should be fragment, which is registered via the router.routes.
if you would like to navigate to the other file, you may consider the window.location.href
I am currently using CefSharp.MinimalExample.Wpf (CEF branch 1750 and CefSharp 33.0.0) to evaluate my issue. I just added a button to the MainView.xaml like this <Button Command="{Binding WebBrowser.BackCommand}">Back</Button>. The buttons enable state is updated on loading a site (once the site is loaded it is pressable). But clicking on it doesn't work to navigate back.
My second approach was to execute a java script snippet on click browser.ExecuteScriptAsync("history.back()"); But this doesn't work either.
Any ideas?
I have the same problem, but your answer gave me an idea, I hope my solution works for you.
The first page showed by the browser is like a blank page, so, when this blank page is loaded, I assign the URL, through FrameLoadEnd event of the browser.
I have a flag to avoid assign the URL more than one time.
Browser.FrameLoadEnd += delegate
{
if (!flag)
{
Browser.Address = "http://www.google.com.mx";
flag = true;
}
};
Looks like with this the problem is solved.
My investigation result is that if you set the URL too early - on creation of the browser object ChromiumWebBrowser until up to about 250ms (try&error value on my machine) - at least the back-function and JavaScript-injection won't work. The Initialized event is not a solution because it is too early. Apart from this the site will be rendered fine and you can browse the web. This was the part which distracted me and let me search elsewhere.
I am writing something like a registration process containing several steps, and I want to make it a single-page like system so after some studying Backbone.js is my choice.
Every time the user completes the current step they will click on a NEXT button I create and I use the router.navigate method to update the url, as well as loading the content of the next page and doing some fancy transition with javascript.
Result is, URL is updated which the page is not refreshed, giving a smooth user experience. However, when the user clicks on the back button of the browser, the URL gets updated to that of a previous step, but the content stays the same. My question is through what way I can capture such an event and currently load the content of the previous step and present that to the user? Or even better, can I rely on browser cache to load that previously loaded page?
EDIT: in particular, I'm trying something like mentioned in this article.
You should not use route.navigate but let the router decide which form to display based on the current route.
exemple :
a link in your current form of the registration process :
<a href="#form/2" ...
in the router definition :
routes:{
"form/:formNumber" : "gotoForm"
},
gotoForm:function(formNumber){
// the code to display the correct form for the current url based on formNumber
}
and then use Backbone.history.start() to bootstrap routing
I have a silverlight project that has many xaml pages. i have an external website that will call the silverlight website so e.g. http://mysilverlightproject:1230.com?queryString1=Page1.xaml.
i want to change the page by passing the values from query string.
is it possible to change the main xaml page to be another page from the query string?
Thanks
string val = string.Empty;
if (HtmlPage.Document.QueryString.ContainsKey(”foo”))
{val = HtmlPage.Document.QueryString["foo"];}
As far as I know you can't change Main page after it is assigned from App class. But you can use Navigation framework and navigate to needed page. In this case you also will be able to use browsers back/forward button.
This post is about navigating from code behind.
Take a look at how a Silverlight Navigation Application works. It will give you the functionality you request.
you can pass pageId to SL application by initparams specific to different URLs and load required page inside SL application instead of default start page
Init params are placed in html and are passed inside SL app, like the following
<param name="InitParameters" value="queryString=Page10" />
Inside you can use SilverlightHost class to get them
SilverlightHost host = new SilverlightHost();
if (host.InitParams.Count > 0)
{
foreach (var c in host.InitParams)
{
if(c.Key == "queryString")
RedirectToUIPage(c.Value) // your method
}
}
I'm writing a VisualForce page to replace an old legacy S-Control.
Originally the Custom S-Control was launched from a Custom Button, and it opened in a new browser window (The S-Control is type HTML, and the Custom Button has Behavior: Display in new window)
For certain old records, I want to do a similar thing from VisualForce.
So: Do HTML S-Controls have a URL that I can launch using a link? In which case, how do I figure out the URL?
Or:
Is there a way of embedding 'Custom Buttons' (that is, the buttons defined in "Setup->Customise->Account->Buttons and Links") into VisualForce pages? If so, I can embed the existing button that knows how to open the S-Control
Or:
Can you suggest some other way of doing this? Key features: Open an S-Control in a new window from VisualForce.
Thanks
Got an answer from this forum post courtesy of aballard:
Basically, the !Urlfor() function can be used to get the URL of an S-Control. So, you can use an outputLink like this:
<apex:outputLink value="{!UrlFor($SControl.my_scontrol_name)}"
target="_blank">Show SControl</apex:outputLink>
If you need to pass an object ID to the S-Control, you can add a second parameter that calls a propery on the custom controller, e.g:
<apex:outputLink value="{!UrlFor($SControl.my_scontrol_name, AccountID)}"
target="_blank">Show SControl</apex:outputLink>
... where AccountID is defined on the custom controller as public string getAccountID()
See also this blog post at SalesforceSource for more info on the UrlFor function.