469,631 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

C# call event in DLL

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

Aug 21 '06 #1
2 5150
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


-------------------------------------------------------------------

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

Aug 21 '06 #2
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

Aug 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by Ricky W. Hunt | last post: by
4 posts views Thread by Paul | last post: by
3 posts views Thread by Ignacio Machin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.