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

  • Thread starter Thread starter Norton
  • Start date Start date
N

Norton

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!
 
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top