473,666 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User control communication within Master page

I have 2 user controls within a master page, and I would like one of
them to call a function in the other.

All the examples I have seen involve a page communicating with the
Master page, or with a user control communicating with the Master
page, not with a user control directly talking to another user
control, bypassing the page itself.

So, I have the following files:
Haep.master - which contains:
Equip.ascx
Compare.ascx
(also there are 16 ASPX pages that inherit from the Master page)

To demonstrate I have tried my hardest to read this forum, here's what
I've got working so far. The aspx pages have a function in them to set
the public property of Equip.ascx. I am currently using

-- in *.aspx.cs:
((Haep)Page.Mas ter).EquipXmlFi le = "myfile";

-- in Haep.master.cs
public string EquipXmlFile
{
get { return ucEquip.XmlFile ; }
set { ucEquip.XmlFile = value; }
}

and this works fine, passing the correct XmlFile parameter to the
Equip.ascx user control. I have not set the @MasterType, so I have had
to cast the Master page. However this still works well for this simple
function.

So, that's an example of what I have got working... now my problem is,
within Equip.ascx there is a function from which I would like to call
a different function in Compare.ascx. Neither of these user controls
are within the *.aspx pages, they are in the Haep.master page. I've
tried casting the Master page and also Compare.ascx from within
Equip.ascx.cs, but I still cannot get hold of the public function I
want.

Ideally I want something like this:
-- in Equip.ascx.cs
private void Something_Click (...)
{
UserControl ucCompare = (...properly casted Compare.ascx user
control...);
ucCompare.DoSom ething(...);
}

-- in Compare.ascx
public void DoSomething(... )
{
// do something
}

Do I need to start looking at events instead, or is there an easy way
I can get the user controls to talk to each other, even if it is via
an intermediate public function within the Master page itself? Any
help would be much appreciated, this is driving me nuts.

Jul 18 '07 #1
0 2186

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2492
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of the functions and I can't find out how to do it. Here is an example of what I do and I get the following Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the...
4
1811
by: Mark | last post by:
I am setting up an asp.net site using the Ektron CMS. Every page in the site uses the same basic template, with the look of the page changing via CSS and an id on the body. The id is shared by all pages in a subsection, e.g. everything in /about/ needs to have <body id="about">. In the past what I've done is set a global variable in index.asp, then include the template to render the page: <% pageid = "about"
20
2417
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the include files to change the layout. When I came to ASP.NET, I used user controls to do a similar thing. I have just been looking at master pages, and it looks like they do the same thing. If so, is there any advantage in using them over the...
1
4015
by: yoknows | last post by:
Hello .Net Gurus. This is my first post here so I apologize in advance if I have not provided the right information. I hope someone has seen this problem before and can tell me what I am doing wrong. I have simplified the problem with the following example: Using asp.net 2.0, I have a Master page template used on default.aspx. >From within the Content tags on that page I placed a Datalist. It is iterating a User control "Inner" with...
2
5537
by: Paras | last post by:
Hi, I have 3 ContentPlaceHolders in the MasterPage. In the 2nd content I have placed a usercontrol which has anchor link. This loads another page (without changing loading the content of ContentPlaceHolder1). But currently this is getting posted back. I have tried in a separate application and tried with 2 ContentPlaceHolders (without user control) by implementing UpdatePanel. That works fine. But with user control it is getting...
1
3619
by: schneider | last post by:
Is it possible to get access to the local resource (App_LocalResources) of an aspx page from within a user control located somewhere else? I have created a user control which I want to add to a page and read values from the page's local resource. But within the code of the user control, I can only access the local resource of the user control itself in its own App_LocalResources folder. Can someone help me please? Cheers, Hannes
1
25002
by: Salim | last post by:
Hi, I'm trying to get UniqueID of a linkbutton. I have 2 web user controls. And a master page. In fisrst web user control there is a datalist. In datalist ItemCreated event, I try to find a linkbutton control which is in the second web user control and in another datalist.
3
5282
by: Mick Walker | last post by:
Hi All, I have a user control on my master page, which exposes 3 public properties (all boolean). Basically by the values of these properties, the user control builds a menu to for users to navigate through the website. I am wondering, how can I set the property of a usercontrol contained within a Master Page, from a content page? Kind Regards
3
1439
by: Cirene | last post by:
When you set the value of a user control in a master page, do you have to reference it differently? Also, do they have to be given different names in the templates? For example, this is what I have.... (uc1 is a user control I defined) MasterPage.master -- FormView#FormView1 --<EditItemTemplate>
0
8869
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.