call c# usercontrol from vb.net page

  • Asp.net 4.6
  • I have a c# user control tested and working with a c# webform, made possible from sample code on EE and SO.
  • I now need to call that c# usercontrol from an older vb.net page but cant work out how to make the delegate work.

the ctl
using System.Configuration;

public delegate void ReturnIdtoPageHandler(string messageToThePage);

public partial class Controls_getProjectId :  System.Web.UI.UserControl
{
    public event ReturnIdtoPageHandler ReturnIdtoPage;

    #region Properties
    public string ProjectId { get; set; }
    public string ProjectDetails { get; set; }
    public string NameMinor { get; set....


    protected void butSelect_Click(object sender, EventArgs e)
    {
        ProjectId = lbResults.SelectedItem.Value;
        string[] separators = { "::", "__" };
        ProjectDetails = lbResults.SelectedItem.Text;
        string[] nms = lbResults.SelectedItem.Text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
        NameMajor = nms[1]; if (nms.Length == 3) { NameMinor = nms[2]; } else { NameMinor = ""; }
        [b]ReturnIdtoPage( ProjectId);[/b]
        
    }

Open in new window


c# webform
        ctlGetProjectId.ReturnIdtoPage += delegate (string message)
        {
            tbProjId.Text = message;
            Label1.Text = ctlGetProjectId.NameMajor + ctlGetProjectId.NameMinor;
        };

Open in new window


tried
    Protected Sub Controls_getProjectId_ReturnIdtoPageHandler(ByVal sender As Object, ByVal e As EventArgs) Handles Controls_getProjectId.ReturnIdtoPageHandler

    End Sub

Open in new window

but the PageHandler is not recognised as an event
LVL 33
Robberbaron (robr)Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
Use addhandler:
https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/addhandler-statement


Public Sub ReturnIdtoPageHandler(ByVal message As String)
  tbProjId.Text = message
  Label1.Text = ctlGetProjectId.NameMajor + ctlGetProjectId.NameMinor
end sub

'add this to your page_load
AddHandler ctlGetProjectId.ReturnIdtoPage, AddressOf  ReturnIdtoPageHandler

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.