Andy5
Andy5

Reputation: 2405

Validators in User Control Not Firing Using VB.Net

I have a wizard control where each step contains a user control.

On each user control (or each step) I have validators, custom validators, required validators, etc. The issue I have is that I am having to write this application in VB.Net, which has been forced on me rather in C#. In the hosting page on its OnLoad event, I usually attach the event by using the usercontrol name.RequiredValidator += usercontrol name.RequiredValidator_Validate. However, in VB.Net I can't seem to do this!

I have tried using a C# to VB.net converter, but this didn't work either.

So, my question is this, how do you attach events in the hosting page from the user control in VB.Net????

Upvotes: 1

Views: 265

Answers (1)

Gromer
Gromer

Reputation: 9931

Say we have this control (pretend I added all the needed attributes):

<asp:Button ID="btn" runat="server" />

In C#, you'd wire up an event like:

btn.Click += btn_Click;

In VB.Net, you'd wire it up like:

AddHandler btn.Click, AddressOf btn_Click

Just apply that to whatever event you are wiring up to. For reference: http://msdn.microsoft.com/en-us/library/ms743596.aspx#Y0

Upvotes: 1

Related Questions