473,499 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control referencing

How do i reference a control in the following scenario?

Master page has an ascx file which show the total items and value in a
shopping cart (using Profile data)

This needs to be updated when the cart is changed / amended.

The file structure =

master1.master with cartTotal.ascx with a label - lblTotal

shoppingCart.aspx with cart.ascx with events - CartGrid_RowUpdating etc

What i need to do is when the CartGrid_RowUpdating event fires i'd like to
reference the lblTotal in the cartTotal.ascx/ master1.master file and update
its contents.

Any suggestions?
May 1 '07 #1
3 1122
This is how I've done it, wouldn't mind other people's input so I'm sure I'm
missing a simple trick somewhere, it shouldn't be this complicated.

Create a class in your App_Code directory called IMyInterface and have this
in it

public interface IMyInterface

{

void MyMethod (int myParam)

}
Now have your shopping cat control implement this;

public partial class cartTotal: System.Web.UI.UserControl, IMyInterface

And implement the MyMethod

void IMyInterface .MyMethod (int myParam)

{

// Update your control here

}

Then in your shoppingCart page;

IMyInterface myInterface = (IMyInterface ) Master.FindControl("cartTotal1");

myInterface.MyMethod (123);


"James Page" <Ja*******@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
How do i reference a control in the following scenario?

Master page has an ascx file which show the total items and value in a
shopping cart (using Profile data)

This needs to be updated when the cart is changed / amended.

The file structure =

master1.master with cartTotal.ascx with a label - lblTotal

shoppingCart.aspx with cart.ascx with events - CartGrid_RowUpdating etc

What i need to do is when the CartGrid_RowUpdating event fires i'd like to
reference the lblTotal in the cartTotal.ascx/ master1.master file and
update
its contents.

Any suggestions?


May 1 '07 #2
Thanks Aidy

Do you have a vb example?

"Aidy" wrote:
This is how I've done it, wouldn't mind other people's input so I'm sure I'm
missing a simple trick somewhere, it shouldn't be this complicated.

Create a class in your App_Code directory called IMyInterface and have this
in it

public interface IMyInterface

{

void MyMethod (int myParam)

}
Now have your shopping cat control implement this;

public partial class cartTotal: System.Web.UI.UserControl, IMyInterface

And implement the MyMethod

void IMyInterface .MyMethod (int myParam)

{

// Update your control here

}

Then in your shoppingCart page;

IMyInterface myInterface = (IMyInterface ) Master.FindControl("cartTotal1");

myInterface.MyMethod (123);


"James Page" <Ja*******@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
How do i reference a control in the following scenario?

Master page has an ascx file which show the total items and value in a
shopping cart (using Profile data)

This needs to be updated when the cart is changed / amended.

The file structure =

master1.master with cartTotal.ascx with a label - lblTotal

shoppingCart.aspx with cart.ascx with events - CartGrid_RowUpdating etc

What i need to do is when the CartGrid_RowUpdating event fires i'd like to
reference the lblTotal in the cartTotal.ascx/ master1.master file and
update
its contents.

Any suggestions?


May 1 '07 #3
Do you have a vb example?

No :) There is a c# to vb converted out there or maybe someone else can
help.
May 1 '07 #4

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

Similar topics

2
4368
by: Hawk | last post by:
I have a custom menu control that I am creating using C#. I am rendering HTML from a StringBuilder in my control to add the needed JavaScript to the HTML output. I need to have the JavaScript...
1
1555
by: Jon Stranger | last post by:
I am trying to build a custom web control based on DataGrid using VS.NET Standard Edition and have a problem referencing the Columns collection. The control has been built in a separate VS.NET...
4
2266
by: Ron | last post by:
I need to write a custom textbox control that references an object located in the Global.asax class, but I can't compile the control into a DLL without including the reference to the project DLL...
3
1039
by: markh | last post by:
Does anyone know where i could find a good website that explains many techniques for direct control referencing? thanks markh
3
1717
by: PJ | last post by:
I am trying to get reference to a Master page from a web user control. However, I cannot seem to even access the type. I have been referencing the master page in forms by declaring the master...
3
5321
by: Mike Jakes | last post by:
I hope that someone can offer a little advice on this one - I've searched the group but can't find an answer. I think that I'm doing something really stupid or missing something trivial, but see...
1
4005
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...
15
2633
by: Jimmy Stewart | last post by:
I want to use a calculated function for the caption on my tab controls. I used the following code: Me.Page28.Caption = "Expenses & "]" This should display the following: " Expenses " where...
4
1814
by: Torben Laursen | last post by:
I want to change the label of a component that I have on a masterpage but I cannot get my hands on it I have a mastepage MP2 that has a button called B2 masterpage MP2 uses masterpage MP1 that has...
2
1466
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
Hi all I have a user control - mycontrol.ascx with various controls within it. mycontrol.ascx is utilised in myPage.aspx I have a class (class1) to carry out various functions, subs etc. How...
0
7169
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,...
0
7385
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...
0
5467
agi2029
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,...
1
4917
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...
0
4597
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...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
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...

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.