473,471 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Referencing a User Control in web form code (C#)

I have dropped a user control onto my .aspx web form.

In VB.Net, I could add:
protected WithEvents myucTest as ucTestCtl

Then, within page load or anywhere else, I could reference the control as
me.myucTest.

How do I do this in C#? I know I probably need a delegate but I am not too
skilled in doing this. Can someone send me a snippet of C# on how to do
this?

Thanks!
Nov 18 '05 #1
2 1582
It's basically the same thing. C# does not have an equivalent of
'withevents', but the rest translates directly.

You don't actually have any events wired up in what you described - if you
declare a variable at the top of the page, you can then access that variable
in Page_Load, since that is just a method in the page.

"Norton" <th********@hotmail.com> wrote in message
news:eK*************@tk2msftngp13.phx.gbl...
I have dropped a user control onto my .aspx web form.

In VB.Net, I could add:
protected WithEvents myucTest as ucTestCtl

Then, within page load or anywhere else, I could reference the control as
me.myucTest.

How do I do this in C#? I know I probably need a delegate but I am not too
skilled in doing this. Can someone send me a snippet of C# on how to do
this?

Thanks!

Nov 18 '05 #2
Ok, that makes sense.

Now, with VB.Net, when I went to actually reference a property on the
control such as:

me.ucTest.CallMe

I did not have to instantiate the control with a 'new'. I guess I'll test to
see how this works in c#.

N
"Marina" <so*****@nospam.com> wrote in message
news:eP**************@TK2MSFTNGP11.phx.gbl...
It's basically the same thing. C# does not have an equivalent of
'withevents', but the rest translates directly.

You don't actually have any events wired up in what you described - if you
declare a variable at the top of the page, you can then access that
variable
in Page_Load, since that is just a method in the page.

"Norton" <th********@hotmail.com> wrote in message
news:eK*************@tk2msftngp13.phx.gbl...
I have dropped a user control onto my .aspx web form.

In VB.Net, I could add:
protected WithEvents myucTest as ucTestCtl

Then, within page load or anywhere else, I could reference the control as
me.myucTest.

How do I do this in C#? I know I probably need a delegate but I am not
too
skilled in doing this. Can someone send me a snippet of C# on how to do
this?

Thanks!


Nov 18 '05 #3

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

Similar topics

1
by: Tony Hedge | last post by:
Hello, I'd like to reference a control in a user control that is not in the user control. For esample, if I had the following in my .aspx: .... <html> <form ID="frmMain"....> ... <asp:Label...
2
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value...
4
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain,...
7
by: Dave | last post by:
I have two forms, Form1 and Form2. From Form2, how do I reference the value in a control on Form1? Or perhaps a more specific question: Form1 contains a textbox with the value of 10. This form...
2
by: Lokhan Wong | last post by:
My question is whether it's possible to change the properties of a panel, that resides on the webform containing the usercontrol, in the usercontrol itself. Like this: <form> <asp:panel...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
6
by: dana lees | last post by:
Hello, I am developing a c# asp.net application. I have 2 forms. In the first webform ('header') i have a label. I want to reference that label from a different form ('user'), in order to...
9
by: Alan | last post by:
Hmmm, I'm not too good with the syntax of referencing a subreport. I have frmInvoice which has the invoice details (e.g. ProductCode, ProductCost etc) in the subform frmInvoiceDetails. I'm trying...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
3
by: Peter | last post by:
Hi, I have a project with an MDI parent form (Main), which can contain any number of MDI children (Document). The Document form contains several user controls, designed as separate projects and...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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
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...
0
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.