How to add references to aspx file

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

In Solution, In Web project Test.aspx file, How can i refer to dll on
page directives. WebDll project(same solution) I dont want to use
codebehind pages such as (test.aspx.cs)
WebProject
Test.aspx
bin
WebProject.dll
WebDll.dll
Webdll
Test.cs

allreay copied webdll to app bin dir.
and ref it.
Anyone can help me out with systax here. or this is a dream
I have tried last couple hours and no luck.

<%@ Page Language="c#" AutoEventWireup="false"
Inherits="WebDll.Test" Src="test.cs"%>
<%@Page Language="c#" AutoEventWireup="false" Inherits="Test"
Src="Test.cs"%>

They all give errors.
could not find or could not load errors
any idea
 
Hi Ken
<%@ Assembly Name="WebDll" %>
I have been dealing with this last 4 hours. There is gotta be solution.
When i put this line on top of my page, Page shows on browser Ok. This
time When i click on the buttons actions from that dll not triggered.
any idea?
 
Test.aspx page
<%@ Assembly Name="WebDll " %>
<%@ Page Language="c#" AutoEventWireup="false" Inherits="Test"%>

<asp:Label runat="server" id="message">Click a button!</asp:Label>

<asp:Button runat="server" id="button1" Text="One" />

Test.cs on WebDll project
public class Test : Page
{
protected Button button1;
protected Label message;
protected void Page_Init(Object sender, EventArgs e)
{
EventHandler clickHandler = new EventHandler(ButtonClick);
button1.Click += clickHandler;
}
public void ButtonClick(Object sender, EventArgs e)
{
if (sender is Button)
{
Button clickedButton = (Button)sender;
message.Text = "You clicked: " + clickedButton.Text;
}
}
}

I have one solution with two project
WebProject // App project
Test.aspx
bin // i have copied the WebDll to Application project and refer
to it
WebProject.dll
WebDll.dll
Webdll // Dll project
Test.cs

when i click on the button aspx page I like to trigger the click event
on webDll.Test.cs which i have referance it
 
Thanks Ken
I got it
It works fine now with the Assembly Name Inherits using together.

4 $ hours mate.
CHeers
 
Matt said:
In Solution, In Web project Test.aspx file, How can i refer to dll on
page directives. WebDll project(same solution) I dont want to use
codebehind pages such as (test.aspx.cs)
WebProject
Test.aspx
bin
WebProject.dll
WebDll.dll
Webdll
Test.cs

allreay copied webdll to app bin dir.
and ref it.
Anyone can help me out with systax here. or this is a dream
I have tried last couple hours and no luck.

Matt,

( I am a newbie, so trust but verify what I have to say. )

As long as the classes you want to use are in an assembly .dll in the
/bin directory of your application ( in IIS admin you have to make the
directory an application directory ), you can reference them simply
with an @import directive in your .aspx file. You dont need the the
@assembly directive.

If you place the .dll into the GAC, you can use @assembly to get at
your assembly. In that case you have to specify the public key and
whatever on the @assembly stmt. ( but, newbie opinion follows, using
the GAC is not a good idea if you ever plan on deploying your
application to a shared hosting site. You might not have access to the
GAC on a shared hoster. )

-Steve
 
Back
Top