I have a MasterPage that has on it several UserControls (*ascx files). I
wish to control the visibility of the controls on the content pages
according to some parameter (for example on a user control that depends on a
param StoreID, for the UserControl to be visible only if StoreID is in the
query string.)
How can I access a UserControl in a MasterPage from a Content page?
I tried this, and variations thereof, but get errors:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim StoreID As Integer = Convert.ToInt32(Request.QueryString("StoreId"))
If Not StoreID.ToString Is Nothing Then
'Master.FindControl("ProductsByStoreAndCategoryUC. ascx").Visible = True
Dim myLocalMasterPage As MasterPage = Me.Master
Dim myControl As UserControl =
myLocalMasterPage.FindControl("CategoriesByStoreUC .ascx")
myControl.Visible = True
End If
End Sub
------------------------------------------
Thank you for any help,
Paul 5 1935
Is "CategoriesByStoreUC.ascx" the id of the user control in the Master page
?
you need to use the id when using FindControl
"Paul" <Pa***********@TheCornerStore.com> wrote in message
news:V8***********@fe12.lga... I have a MasterPage that has on it several UserControls (*ascx files). I wish to control the visibility of the controls on the content pages according to some parameter (for example on a user control that depends on a param StoreID, for the UserControl to be visible only if StoreID is in the query string.) How can I access a UserControl in a MasterPage from a Content page?
I tried this, and variations thereof, but get errors:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim StoreID As Integer = Convert.ToInt32(Request.QueryString("StoreId"))
If Not StoreID.ToString Is Nothing Then
'Master.FindControl("ProductsByStoreAndCategoryUC. ascx").Visible = True
Dim myLocalMasterPage As MasterPage = Me.Master
Dim myControl As UserControl = myLocalMasterPage.FindControl("CategoriesByStoreUC .ascx")
myControl.Visible = True
End If
End Sub
------------------------------------------
Thank you for any help, Paul
Yes it is, Thanks,
Paul
"Swanand Mokashi" <sw***********@swanandmokashi.com> wrote in message
news:ui**************@TK2MSFTNGP05.phx.gbl... Is "CategoriesByStoreUC.ascx" the id of the user control in the Master page ? you need to use the id when using FindControl
"Paul" <Pa***********@TheCornerStore.com> wrote in message news:V8***********@fe12.lga...I have a MasterPage that has on it several UserControls (*ascx files). I wish to control the visibility of the controls on the content pages according to some parameter (for example on a user control that depends on a param StoreID, for the UserControl to be visible only if StoreID is in the query string.) How can I access a UserControl in a MasterPage from a Content page?
I tried this, and variations thereof, but get errors:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim StoreID As Integer = Convert.ToInt32(Request.QueryString("StoreId"))
If Not StoreID.ToString Is Nothing Then
'Master.FindControl("ProductsByStoreAndCategoryUC. ascx").Visible = True
Dim myLocalMasterPage As MasterPage = Me.Master
Dim myControl As UserControl = myLocalMasterPage.FindControl("CategoriesByStoreUC .ascx")
myControl.Visible = True
End If
End Sub
------------------------------------------
Thank you for any help, Paul
as in -- that fixed it ??
"Paul" <Pa***********@TheCornerStore.com> wrote in message
news:mo***********@fe12.lga... Yes it is, Thanks,
Paul
"Swanand Mokashi" <sw***********@swanandmokashi.com> wrote in message news:ui**************@TK2MSFTNGP05.phx.gbl... Is "CategoriesByStoreUC.ascx" the id of the user control in the Master page ? you need to use the id when using FindControl
"Paul" <Pa***********@TheCornerStore.com> wrote in message news:V8***********@fe12.lga...I have a MasterPage that has on it several UserControls (*ascx files). I wish to control the visibility of the controls on the content pages according to some parameter (for example on a user control that depends on a param StoreID, for the UserControl to be visible only if StoreID is in the query string.) How can I access a UserControl in a MasterPage from a Content page?
I tried this, and variations thereof, but get errors:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim StoreID As Integer = Convert.ToInt32(Request.QueryString("StoreId"))
If Not StoreID.ToString Is Nothing Then
'Master.FindControl("ProductsByStoreAndCategoryUC. ascx").Visible = True
Dim myLocalMasterPage As MasterPage = Me.Master
Dim myControl As UserControl = myLocalMasterPage.FindControl("CategoriesByStoreUC .ascx")
myControl.Visible = True
End If
End Sub
------------------------------------------
Thank you for any help, Paul
No, given that the control on the Master page is called
"CategoriesByStoreUC.ascx", how can I access the visibility of this control
from a Content Page, say the StoresPage.aspx?
Thanks
Paul
"Swanand Mokashi" <sw***********@swanandmokashi.com> wrote in message
news:OB**************@TK2MSFTNGP04.phx.gbl... as in -- that fixed it ??
"Paul" <Pa***********@TheCornerStore.com> wrote in message news:mo***********@fe12.lga... Yes it is, Thanks,
Paul
"Swanand Mokashi" <sw***********@swanandmokashi.com> wrote in message news:ui**************@TK2MSFTNGP05.phx.gbl... Is "CategoriesByStoreUC.ascx" the id of the user control in the Master page ? you need to use the id when using FindControl
"Paul" <Pa***********@TheCornerStore.com> wrote in message news:V8***********@fe12.lga... I have a MasterPage that has on it several UserControls (*ascx files). I wish to control the visibility of the controls on the content pages according to some parameter (for example on a user control that depends on a param StoreID, for the UserControl to be visible only if StoreID is in the query string.) How can I access a UserControl in a MasterPage from a Content page?
I tried this, and variations thereof, but get errors:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim StoreID As Integer = Convert.ToInt32(Request.QueryString("StoreId"))
If Not StoreID.ToString Is Nothing Then
'Master.FindControl("ProductsByStoreAndCategoryUC. ascx").Visible = True
Dim myLocalMasterPage As MasterPage = Me.Master
Dim myControl As UserControl = myLocalMasterPage.FindControl("CategoriesByStoreUC .ascx")
myControl.Visible = True
End If
End Sub
------------------------------------------
Thank you for any help, Paul
assigning such an Id is not throwing an "'CategoriesByStoreUC.ascx' is not a
valid identifier." errror ??? -- it should !!
Change the id to not use the .ascx and you can say call it
"CategoriesByStoreUC1" and then use the following in your aspx page :
CategoriesByStoreUCaddComments =
(CategoriesByStoreUC)Master.FindControl("'Categori esByStoreUC1");
assuming your web control type is CategoriesByStoreUC and it should work
"Paul" <Pa***********@TheCornerStore.com> wrote in message
news:HU************@fe12.lga... No, given that the control on the Master page is called "CategoriesByStoreUC.ascx", how can I access the visibility of this control from a Content Page, say the StoresPage.aspx?
Thanks
Paul
"Swanand Mokashi" <sw***********@swanandmokashi.com> wrote in message news:OB**************@TK2MSFTNGP04.phx.gbl... as in -- that fixed it ??
"Paul" <Pa***********@TheCornerStore.com> wrote in message news:mo***********@fe12.lga... Yes it is, Thanks,
Paul
"Swanand Mokashi" <sw***********@swanandmokashi.com> wrote in message news:ui**************@TK2MSFTNGP05.phx.gbl... Is "CategoriesByStoreUC.ascx" the id of the user control in the Master page ? you need to use the id when using FindControl
"Paul" <Pa***********@TheCornerStore.com> wrote in message news:V8***********@fe12.lga... >I have a MasterPage that has on it several UserControls (*ascx files). >I wish to control the visibility of the controls on the content pages >according to some parameter (for example on a user control that depends >on a param StoreID, for the UserControl to be visible only if StoreID >is in the query string.) > How can I access a UserControl in a MasterPage from a Content page? > > I tried this, and variations thereof, but get errors: > > Protected Sub Page_Load(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Me.Load > > Dim StoreID As Integer = > Convert.ToInt32(Request.QueryString("StoreId")) > > If Not StoreID.ToString Is Nothing Then > > 'Master.FindControl("ProductsByStoreAndCategoryUC. ascx").Visible = > True > > Dim myLocalMasterPage As MasterPage = Me.Master > > Dim myControl As UserControl = > myLocalMasterPage.FindControl("CategoriesByStoreUC .ascx") > > myControl.Visible = True > > End If > > End Sub > > ------------------------------------------ > > Thank you for any help, > > > > Paul > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve Franks |
last post by:
I am trying to access strongly typed properties in a page's master page from
the content page. I followed an article that describes how to do this, and
it seems quite straight forward. However...
|
by: Alexander Widera |
last post by:
Hi,
the situation is the following:
There is this masterpage:
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="mymaster.master.cs" Inherits="mymaster" %>
<%@ Register...
|
by: RedHair |
last post by:
I have a ASP.NET 2.0 web page which inherits a customized base page class
and have a master page,
their relation is as below
Customized base page class --> web page --> master page
How to...
|
by: RedHair |
last post by:
I have a base page class A which inherits System.Web.UI.Page class
then a aspx page B inherits class A and have a master page C.
There is a property D (a string variable) in the master page C.
...
|
by: ivanpais |
last post by:
Hi,
I have a Web User Control, Lets say "Foo.ascx", that contains a button
"btnFoo".
I have a Master Page "Bar.master", that has a label "lblBar". This
label is exposed by a public property...
|
by: Boris Yeltsin |
last post by:
OK, on my Master Page I have a control:
<a id="hypTabAccount" href="#" runat="server">Account</a>
Now, in the code-behind (Root.master.vb) I can refer to it simply thus:
...
|
by: pierre |
last post by:
Hi,
I have a DataList inside a UserControl, which I use on a MasterPage.
My ContentPage lists items which a user can add to his/her shopping
basket. Can someone PLEASE let me know how I can...
|
by: =?Utf-8?B?SmF5IFBvbmR5?= |
last post by:
I am trying to access a Public property on a Master Page from a Base Page.
On the content pages I have the MasterType Directive set up as follows:
<%@ MasterType virtualpath="~/Master.master" %>...
|
by: eselk2003 |
last post by:
I'm just starting out with VWD 2008, and new to ASP .NET.
I have a master page which displays one record for an Access database
based on an ID number in the query string. Then I have a content...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |