The ASP.Net Page class is a class. You can't just put a block of code
anywhere you want to in a class. It has to go inside a function, such
as the
Page_Load Event Handler.
Hmmm, I guess when you put it like that it explains a few things but
makes life a whole lot more difficult, or at least a change in attack
method!
I come from an ASP/PHP coding background and am used to be able to just
inject server generated stuff anywhere I like. I'm going to try and tag
along with this thread because I'm experiencing the exact same issue at
the minute.
I have written a user control which basically just creates a nice
themed box in the style of my site, the content for the control is
placed within the tags, everything works fine until I add <% %>
anywhere like so:
Code:
--------------------
<Box:ShadedBox Width="90%" BoxTitle="Registration" runat="server">
<%="hi" %>
</Box:ShadedBox>
--------------------
And the page falls over with the error "Code blocks are not supported
in this context". Is there any way of injecting server side code into
this section WITHOUT resorting to using the page_load method? I want to
be able to keep some of my code in the aspx file rather than the aspx.cs
code-behind file.
Regards,
Anthony Williams
--
ant177
------------------------------------------------------------------------
ant177's Profile:
http://www.highdots.com/forums/m1564
View this thread:
http://www.highdots.com/forums/t638059