473,499 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code blocks are not supported in this context

What does this mean, have been doing services and windows apps for awhile
now, don't remember doing anything special to get them to work

tried
<script runat="server"> or whatever it was
string sContent;
sContent = GetContent("Default");
Response.Write(sContent)
</script>

<%
string sContent;
sContent = GetContent("Default");
Response.Write(sContent)
%>

GetContent is a declared this way public string GetContent(string pPage)

Am I doing something wrong or not have something set?

John
Nov 18 '05 #1
2 12549
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.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"John Cantley" <jc*******@hotmail.com> wrote in message
news:ew**************@TK2MSFTNGP09.phx.gbl...
What does this mean, have been doing services and windows apps for awhile
now, don't remember doing anything special to get them to work

tried
<script runat="server"> or whatever it was
string sContent;
sContent = GetContent("Default");
Response.Write(sContent)
</script>

<%
string sContent;
sContent = GetContent("Default");
Response.Write(sContent)
%>

GetContent is a declared this way public string GetContent(string pPage)

Am I doing something wrong or not have something set?

John

Nov 18 '05 #2
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

Dec 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
33308
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
20
5900
by: Hung Jung Lu | last post by:
Hi, I know people have talked about it before, but I am still really confused from reading the old messages. When I talk about code blocks, I am not talking about Lisp/Ruby/Perl, so I am not...
20
1980
by: Doug Holton | last post by:
Is there any metaclass trick or something similar to allow anonymous code blocks? I'd like to be able to let users do something like this fictitious example: b = Button() b.OnClick =: print...
35
1254
by: Geronimo W. Christ Esq | last post by:
Are there any scripts or tools out there that could look recursively through a group of C/C++ source files, and allow unreferenced function calls or values to be easily identified ? LXR is handy...
1
1435
by: Jeff Thies | last post by:
I have a number of blocks of content (product items) that I want to wrap naturally at the end of the line. float: left has the unhappy habbit of stacking up where the lowest extending block is. I...
7
2362
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one...
0
1565
by: lazaridis_com | last post by:
Colored Code Blocks Pudge generated documentation can contain colored code blocks, using the rst directive "..code-block:: Python" (an other languages supported by SilverCity). ...
27
2684
by: David Golightly | last post by:
This is just a quick poll for all you web devs out there: What browsers do you test on/are concerned about compatibility with? Obviously, you're going to test on current-generation browsers such...
0
1937
by: peridian | last post by:
Hi, I wanted a web page where I could post code to, and have it appear in coloured formatting based on the context of the code. Most of the techniques I have seen for this involve complex use...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.