Master/Detail with multiple detail pages with non-related content - xamarin.forms

How can I create a Master-Detail page application with multiple detail pages, which have nothing to do with each other? The content of the detail pages is completely different. Thanks.

Conceptually, all you have to do is assign the Detail property based on whatever event you want to trigger the navigation
// assuming Page1 and Page2 are already instantiated
Button1 => MDPage.Detail = Page1;
and ...
Button2 => MDPage.Detail = Page2;
note for this to work, your Master page will need to have a reference to the MasterDetail - you can either explicitly do this, or use Application.Current.MainPage to get the reference, or even use MessagingCenter

Related

Refreshing caller listpage form

I need to call parent form but my parent form is a listpage form.
As I know I can't add new methods to list page forms i need to add this method to the interaction class of related list page form. But I do not have an idea how to do it.
Would you have any suggestion for me?
You have two options:
Set the AutoRefreshData on the menu item on the list page. This will refresh the list page, I am not sure when (maybe it works best on action menu items).
Call element.args().record().datasource().research(true); from the child form.
You can refresh a datasource of a calling record.
You need to cast element.args().record().datasource() to FormDatasource so you can call research() or executeQuery() depending of you needs.
Also you can/must check if record is from a form by using method on common isFormDatasource(). If this is true than this record is from form.
If you need to refresh parent from another form you should do it in closeOk() method of this form or at the end of you logic in a class.

How do I create a function common to all the pages in ASP.net?

I'm making a website that has a menu on all the pages that needs to be changed frequently. Right now I'm copying the code of the menu in all the pages, and so, if the menu needs to be changed, I have to open each page and change the menu there.
Is there any way by which I could define a function in a file somewhere that just writes the menu code using Response.Write() and then keep calling that function on all the pages that need the menu? That way whenever I'd need to make changes to the menu, I'll only make it in the function definition.
Have a look at a user control or master pages. Be more elaborate, so we can help you better.
It sounds like you should consider using a user control for the menu.
Master page is the perfect candidate.
Add the menu in master page.
You can also create a user control for this.
But if you want a function for doing a common task through out the site then create a class
and add the function is that class. Create an object of that class and call the function
anywhere in the site.
If you define a Menu in your Master Page it should refelect in all child pages.
All you need to do is create a Master Page and define your Menu in that.
After that you should create your child page using option >> WebForm using MasterPage
Apart from that for any other functions which are in Master page you can call them in your child page like this:
You can call method inside a MasterPage like this:
var master = Master as MyMasterPage;
if (master != null)
{
master.Method();
}

Page Navigation with MVC3

I'm currently looking for a good way to implement navigation between pages (without using any kind of dialogs) - particularly where a page is shared by more than one other page.
Example
There are three pages:
ProductEdit
OrderListItem
ProductList
The ProductEdit page can be navigated to from both the OrderItemList and the ProductList pages.
The ProductEdit page has a cancel and an update action for it. When the user clicks one of these actions I need control to return back to the page it came from.
Multiple Levels
Any ideas on the best way to implement this. I also need to support this working at more than one level.
Related Posting
This is all MVC3 related but is very similar to another StackOverflow posting: Web page navigation
Many Thanks!
You can use the ProductEdit Page as partial view , and then check the ViewBag.Title to know in which page it came from. For example:
In OrderListItem Page :
#{ ViewBag.Title = "OrderListItem";}
#Html.Partial("ProductEdit");
and same in ProductList Page.
In ProductEdit Page check :
If ( ViewBag.Title = "OrderListItem")
//send value to your control with the title as paramter...

ASP.NET - How to propagate events with nested user controls

I have nested controls on a page. Ex:
Page
-ChildControl1 (of type AllOfMyItems)
-ChildControl2 (of type ListOfItems)
-ChildControl3 (of type MyItem <- this one fires event)
When child control raises an event, I want page to handle that event. What is a good way to do this?
Events and delegates seem like a good idea to use here.
So I'm trying to do the following on Page_Init of my Page:
MyItem.SomethingHappened += doStuff();
what is a good way to do this?
I assume that you don't have direct access to ChildControl2 from your page and thats your problem.
One option is to bubble the event from one UserControl to it's parent UserControl and so on until your page handles the ParentControl.SomethingHappened event. This way is recommended if the usercontrols aren't always nested like in this example.

ASP.Net - How to access masterpage Object from regular page?

In a project I'm working on, the master page codebehind does a load of complex checks and confirmations that decide the navigation list displayed on the TreeView of the page. Now, I need a way to access this list from another front-end page, such as "frontpage.aspx".
This serves two purposes. One, the masterpage will hide pages on the navigation list the user shouldn't have access to, but the user can still enter the page by typing the page name into the URL manually. By being able to browse through the TreeView, I can isolate the whole authorization into a single method by simply checking if the page name exists within the currently used TreeView.
Two, this will allow me to easily change the displayed content of any page without checking the database or storing sessions for whatever specific rights the current user has, as I can just look if the TreeView contains "Products Admin" for example, and then use that to hide or display the section of the page that has to do with "Product Admin" functionality.
So, any tips on how to do this, or if it's even possible?
Assuming that frontpage.aspx is a content page you can definitely access the master page from it.
For example this code will find a TextBox and Label controls that are on the master page. You should be able to adapt it to find your TreeView:
// Gets a reference to a TextBox control inside a ContentPlaceHolder
ContentPlaceHolder mpContentPlaceHolder;
TextBox mpTextBox;
mpContentPlaceHolder =
(ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
if(mpContentPlaceHolder != null)
{
mpTextBox = (TextBox) mpContentPlaceHolder.FindControl("TextBox1");
if(mpTextBox != null)
{
mpTextBox.Text = "TextBox found!";
}
}
// Gets a reference to a Label control that is not in a
// ContentPlaceHolder control
Label mpLabel = (Label) Master.FindControl("masterPageLabel");
if(mpLabel != null)
{
Label1.Text = "Master page label = " + mpLabel.Text;
}
For more info see - http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx
You should be able to access it through the Master property, i.e.:
TreeView tv = Master.MyTreeViewControl;
or
TreeView tv = (TreeView)Master.FindControl("MyTreeViewControl");
This page on MSDN has more information about working with master pages programmatically.
You can access any public functions from the masterpage refering to Page.Master and casting this property to your master-page;
((Styles_Master)Page.Master).IsMyProperty = "new value";

Resources