I have a simple master page (master.aspx), which has 3 link buttons namely HomeLBTn-which redirects the users to home.aspx, LoginLBtn-to login.aspx, RegisterLBtn-to Register.aspx
Every page in my project inherits the master page. And home.aspx also inherits the master.aspx, but i don't want the home.aspx to inherit the HomeLBtn, I want it to inherit the remaining 2 LBtn's, but not the HomeLBtn. How can i incorporate this condition into Home.aspx
Please help me
Thanks in anticipation
One way would be to find the control in the MasterPage and set its visibility to false:
Page.Master.FindControl("HomeLBtn").Visible = False
This would be done in the Page_Load (or some other lifecycle event) on the page that shouldn't show the Home button.
In master.aspx, define Register and Login link buttons, and a content placeholder for where the Home button would go. Then have Home.aspx inherit master.aspx. Then create a 2nd master page (master2.aspx) that inherits from master.aspx. In master2, add the Home link button in the content placeholder, and have your other pages inherit from master2.
You can do something like this in the master page ( Check what the child page is )
//If the child page is viewing an order then disable the new request button
if (this.ContentPlaceHolder1.Page is OrderView)
{
base.RemoveMenuItem("New Request", mnuSettings);
}
Note: base.RemoveMenuItem is a method of my base page
http://wraithnath.blogspot.com/2010/09/how-to-hide-show-controls-on-master.html
Another option would be to add a property to the child page and master page and use session data to hide and show buttons.
eg. in Child Page:
protected MyCustomMasterPage CustomMasterPage
{
get
{
return this.Master as MyCustomMasterPage;
}
}
In your master page you could have a session variable you can set to hide and show the buttons
public bool HomeVisible
{
get
{
return (bool) Session["HomeVisible"];
}
set
{
Session["HomeVisible"] = value;
}
}
You would then check the HomeVisible property when loading the master page to show / hide the button. You can then set this from the child page.
this.MyCustomMasterPage.HomeVisible = false;
Maybe not the best ways but they work
Related
I have two pages: Page A and Page B. I want that the user on my application be able to pass since page A to page B, but I don,t want he to be able to pass since page B to page A. How can I do that?
I tryed to use Navigation Page and deactivate the return Button, but I couldn't find how deactivate it.
If you don't need to "Navigate" you can set
Application.Current.MainPage = new PageB();
and override OnBackButtonPressed()
protected override void OnDisappearing()
{
//back button logic here
return true;
}
I have masterdetail page and there is left menu in it. Its working fine during user is on masterdetail page. But When user move from master detail page to simple content page(that is not part of master detail page), on this content page if he swipe from left to right left menu opens.
How I can disable the left menu on this content page? and why left menu is showing on simple content page while it is not part of the master detail page?
If you're still looking for a solution, you can do it like so:
IsGestureEnabled = false;
You can continue to use
await Navigation.PushAsync(new PageWhichWontOpenTheMenu());
To use it, simply get the RootPage (the MasterDetailPage) on the OnAppearing method like so:
protected override void OnAppearing(){
base.OnAppearing();
(Application.Current.MainPage as RootPage).IsGestureEnabled = false;
}
Tell me if it works for you, cheers!
You can only disable the gesture from master details page.
It can be solve by notifying that the current page is not master page:
1)When we are setting the Master details page by
Detail = new NavigationPage((Page)Activator.CreateInstance(page));
IsGestureEnabled = true;// always set it true when setting a page to master page
2)Use MessagingCenter from MasterDetails Page for notifying that the current page is not a master page:(inside the master page constructor)
MessagingCenter.Subscribe<string>(this, "DisableGesture", (sender) =>
{
if(sender == "0")
{
IsGestureEnabled = false;
}
else
{
IsGestureEnabled = true;
}
});
3)when you navigate from a nornal content page,and you dont want to open the master menu from here then notify the master page IsGestureEnabled = false;
//content page OnAppearing method
protected override void OnAppearing()
{
MessagingCenter.Send<string>("0", "DisableGesture");
}
do this for all your content page,where you dont want to open master menu.
****and remember that which pages you are setting as master page,for those pages onappearing method send messaging center with value "1"
protected override void OnAppearing()
{
MessagingCenter.Send<string>("1", "DisableGesture");
}
Thanks
Better yet what you can do in your OnMenuItemSelected event for your SideMenu list is check for the type that you want to Disable the SideMenu for and then set IsGestureEnabled to false when navigating to that page:
private void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = (SideMenuItem)e.SelectedItem;
var page = item.TargetType;
if (page == typeof(PageToDisableMenu))
IsGestureEnabled = false;
Detail = new NavigationPage((Page)Activator.CreateInstance(page));
IsPresented = false;
}
I know this answer is late but I hope it helps someone in the future :).
You probably use Detail.Navigation.PushAsync(...) instead of that use Navigation.PushAsync(...)
To really disable, I found one way, use Navigation.PushModalAsync(...). But this way, you don't have the navigation bar at the top anymore. You can build one yourself though.
What worked for was to disable the whole MasterDetailPage with the IsEnabled property.
In may case executing a process from an option menu (not navigation or change the Detail page) and I needed to block any interaction of the user with the page.
Hope this helps.
Regards
I have two iframes on my page, frameOne and frameTwo.
I'm trying to refresh/reload frameOne from a script running in frameTwo.
function reload(){
srcLink = parent.document.getElementById('frameOne').src;
parent.document.getElementById('frameOne').src=srcLink;
}
This works but it refreshes to the initial value of the iframe.
IE:
If the parent page loaded with that iframe's src set to 'google.com' but then changed to (due to a user action) 'yahoo.com' my code will refresh that page to 'google.com', the link it was set to when the page was loaded. I would like to take into account the change of link and refresh that one.
Try this from frames[1] (the 2nd iframe page):
function changeFrameSrc(becauseURL, changeURL){
var bc = new RegExp(becauseURL, 'i');
if(bc.test(location)){
parent.frames[0].src = changeURL;
}
}
I have a master page with a user control added. The user control has properties, price and exchange rate.
I can get the control from a normal page by using master.findcontrol but it sees it as just a normal user control, so i cant get access to the controls properties, price or exchange rates.
Is there a way to solve this?
Thanks to all who view
Why not expose your custom control as a property of the masterpage. Then you can reference it like:
Master.YourCustomControl.YourCustomProperty
You have to cast the control to your custom control in order to access the properties of your custom control,
var control = (YourCustomControl)Master.FindControl("YourCustomControl");
I guess you have not exposed any properties for your custom control, Try the following,
public partial class YourControl: System.Web.UI.UserControl
{
public string textboxtext{
get { return tb_Textbox.Text ;}
set { tb_Texbox.Text = value; }
}
}
Once you create properties for all the customizable properties for your custom control, you then can access or modify them.
I have a custom UserControl (inherits System.Web.UI.UserControl) with this property, which should be set to a URL on the site that you want to link to:
[DefaultValue("~/NewsItem.aspx"), UrlProperty("*.aspx")]
public string InternalItemViewUrl
{
get { return _internalItemViewUrl; }
set { _internalItemViewUrl = value; }
}
The control will present the URL picker drop-down correctly, but if you select a URL from the list, it does not change it to a site-relative "~/foo.aspx" link, like HyperLink does, but instead only gets "foo.aspx" which does not work (the control is in /controls and the page obviously is not). If you scroll all the way down and use "Pick URL..." which opens the full pop-up window, a page selected in that dialog does get converted to "~/foo.aspx"
Am I missing something obvious here to make this work?
Check out the attributes on the HyperLink, especially the [Editor] attribute.
[DefaultValue(""),
WebSysDescription("HyperLink_NavigateUrl"),
UrlProperty, Bindable(true), WebCategory("Navigation"),
Editor("System.Web.UI.Design.UrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
It doesn't matter where the control is, the url is relative the page the control is placed on.
So if the control is placed on page "foo.aspx" and it references a page "foo2.aspx" (that is in the same directory as "foo.aspx"), then just haveing "foo2.aspx" in the control's url property will work.