how to navigate from MainPage.xaml to other page. - silverlight-4.0

In my apllication there are two from.The default form that is the MainPage.xaml and another form called login.xaml.
I have a button on MainPage.xaml,and my requirement is when the user click that button the Login page should be navigated.
This is my first experience in silverlight can i get that easily understandable code.

this.NavigationService.Navigate(new Uri("/Pagename", UriKind.RelativeOrAbsolute));
In this give your xaml or aspx (/Pagename) only no need to mention .xaml or .aspx

Instead of navigating, you could use a Childwindow
Otherwise, I think, you would have to use the Silverlight navigation framework, but this is quite complex. I'd suggest you to first have a child window pop up if you want to do something!

On Button Event
this.Content=new Login();

Related

How to use/handle a loader in an MVC app?

in a ASP.NET MVC application that I am currently working there are multiple places in a single page that the user can click. So there is a main menu that's in _layout and for each inidividual page there can be links associated with that page.
I am trying to use a loader which will be shown on every click, mainly where the response takes time but for now it's for every click.
For example in the home page, from the main menu the user can click Students and the loader should come up and hide when the page loads completely. On the students page there can be an ajax call that gets data and binds it to the grid.
So from the time the user clicks on a menu link and the page loads the loader is active/shown. It's hidden once the page loads completely.
The grid can have editing functionality and when the user clicks on any of the CRUD links the loader should show and hide.
I am looking at suggestions on implementing this requirement.
If I can hookup any of the MVC events, that would be cool as I want less of Javascript/jQuery stuff but if Javascript/jQuery is the way then that's fine too.
Currently I don't have anything so anypointers are appreciated.
Assuming AJAX is being used
I don't see a way to keep this server-side without a middle page with a redirect being used (which would just be unnecessary bloat). And, since you're not opposed, you can implement this fairly easily using jQuery and something like blockUI.
I'll let you play with refining the binding to only links you care about, but for now we'll assume all links. Also, MVC should be using jQuery for things like Ajax.Actionlink so we can hijack events like $.ajaxStart and $.ajaxStop:
function showLoadingScreen(enabled){
return enabled ? $.blockUI() : $.unblockUI();
}
$(document).ajaxStart(function(){
showLoadingScreen(true);
}).ajaxStop(function(){
showLoadingScreen(false);
});
Later on you can maybe apply classes to the links you care about and just bind to them (instead of $.ajaxStart) but I'll leave that up to you.

asp:Fileupload does not work in ajaxToolkit:AccordionPane

I am using asp:FileUpload in ajaxToolkit:AccordionPane but it always shows HasFile=false.
I am not using any update panel. The structure of the page is as below.
MAster page-->Master page-->.aspx page-->User control-->User control-->AccordionPane-->File upload control.
I have also set Page.Form.Attributes.Add("enctype", "multipart/form-data"). still it shows HAsFile=false.
How can I upload image file?
Till now there is one solution in my view... having another small page with only fileupload controll and call it as popup on button click - and place the button inside accordion pane.
its just a way-around... still looking for proper solution....

Can we Use masterPage in silverlight4 application

Is it Possible to use masterpage with silverlight4 application?
The Silverlight navigation template project available in VS2010 gives you the equivalent of a master page in the form of MainPage.xaml.
There is no master page concept in silverlight. try using usercontrols and implement the master page. Iframe and silverlight controls should do the trick.
Anyways let us wait and hear from an expert if there is a better work around.

Prevent user from navigating directly to a page in silverlight

Is there a way to prevent users from navigating directly to a page in Silverlight 4?
Thank you.
You can override the Page.OnNavigatingFrom method and cacel the navigation before it happens.

Windows phone Navigation issue

I have an application where from the MainPage.xaml I navigate to a page called say two.xaml.
In Two.xaml I then navigate to Three.xaml..
Now for Three.xaml I want to navigate back to the mainPage.Xaml.
In Three.xaml if I do
this.NavigationService.GoBack();
this.NavigationService.GoBack();
I get an InvalidOperationException.
If I do
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
the system will crate another instance of MainPage.xaml, which I do not want as it will lose its original state.
Anyone have solutions to this issue?
you can save the actual state for example in the State-Property of the PhoneApplicationService Class, then Navigate through your pages and when getting back to the MainPage you just implement the OnNavigatedTo()-method of the MainPage and load the State-Data.
Hope this helps...
AFAIK, you are not supposed to manipulating the back stack in your app.
What cordellcp3 says may be a good idea to implement
If your intent is to navigate in this way:
MainPage->PageTwo->PageThree
User presses Back Button and goes to MainPage you can use this:
NavigationService.RemoveBackEntry()
documentation
hope it helps