Calling code-behind function from in-line code page

  • Thread starter Thread starter Fred Armitage
  • Start date Start date
F

Fred Armitage

I have a fairly complex application written using a vb code-behind dll.
However, I'd like to write one particular aspx page utilising in-line code
so that it can easily be modified as needed by the end user, and yet still
utilise some functions in the code-behind dll.
Is this possible? (How?)
 
Fred,

I'm not 100% positive but I don't think you can do this. To use the
codebehind file or inline code you change the page directive's
AutoEventWireup attribute. Since it has to be set to true or false I think
you can only use one or the other.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
I disagree. It is possible to use code behind and inline code at the same
time. Setting AutoEventWireup to true doesn't prevent events in the parent
class (in the code behind dll) from getting executed.
So you develop you code behind dll the normal way, and set AutoEventWireup
to true to handle page events (like Page_Init and Page_Load) in the aspx
file.

or better override the methods that raises these events, for example
<script language="c#" runat="Server">

protected override void OnLoad(EventArgs e)
{
// here execute the code you want to be executed before the Load event
is raised
base.OnLoad(e);
// here execute the code you want to be executed after the Load event is
raised
}
</script>

You can also decide not to call base.OnLoad if you don't want the Load event
to be fired. This gives more flexibility.
you can also use asp style inline code
for example
<table>
<%
for(int i = 0; i < 10; i++)
{
%>
<tr>
<td><%=i%></td>
<td>Hello World</td>
</tr>
<%
}
%>
</table>
 
Back
Top