C# call event in DLL

P

parkchan

Hi everyone,

I have a problem calling an event in a DLL from a C# code. The dll is
written in VB.NET and I don't have the source code for it so I can't
modify it. The DLL came with an aspx file and they work fine together,
but the problem arose when I tried to convert aspx ("Page") into ascx
("UserControl"). After changing the file name to ascx and declaration
at the top of the page common web controls that have calles to events
in the DLL cannot sees them even though I've imported the dll at the
top of the control in declaration.

----------------------- This works --------------------------
<%@ Page Language="C#" Codebehind="TestCode.aspx.vb"
Inherits="TestDll.TestCode" %>
.....
<!-- code below can see the event -->
<asp:button id="cmdTest" onClick="event_in_dll"></asp:button>
-------------------------------------------------------------------

----------------------- This DOESN'T work --------------------------
<%@ Control Language="C#" %>
<%@ Imports Namespace="TestDll" %>
.....
<!-- code below can NOT see the event -->
<asp:button id="cmdTest" onClick="event_in_dll"></asp:button>
-------------------------------------------------------------------

I've tried everything that came across but had no luck. I have to
convert it to a User Control.
Could anyone help me with this please?

Thanks in advance,
Chan
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,
<!-- code below can see the event -->
<asp:button id="cmdTest" onClick="event_in_dll"></asp:button>

What this means is that to call a method declared in the parent class of the
current page. If you go to the aspx file you will see in the top a @Page
directire it will especify the parent class. All the methods implemented in
the parent class are part of the new class that will be generated by
compiling the aspx.

Now if you convert it to a user control the page including the control will
have to derive from the same class.

Or a possible solution could be to have the parent class of the new page
(the one that will include the control) to derive from the class defined in
the dll instead of Page as it usually the case.


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
 
P

parkchan

Hi Ignacio,
Or a possible solution could be to have the parent class of the new page
(the one that will include the control) to derive from the class defined in
the dll instead of Page as it usually the case.

I've created a new page which inherits the dll and embeded the user
control in that page, and it looks like working. I am sure because I am
getting an "object reference not set" error. I guess what I'm trying is
sort of working but having another trouble inside the DLL.

Thank you for your reply,
Chan
 

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

Top