Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Code blocks are not supported in this context

Reply
Thread Tools

Code blocks are not supported in this context

 
 
John Cantley
Guest
Posts: n/a
 
      12-10-2003
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


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      12-11-2003
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" <> wrote in message
news:ew#...
> 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
>
>



 
Reply With Quote
 
 
 
 
ant177
Guest
Posts: n/a
 
      12-14-2005

> 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, suc
> as the
> Page_Load Event Handler.


Hmmm, I guess when you put it like that it explains a few things bu
makes life a whole lot more difficult, or at least a change in attac
method!

I come from an ASP/PHP coding background and am used to be able to jus
inject server generated stuff anywhere I like. I'm going to try and ta
along with this thread because I'm experiencing the exact same issue a
the minute.
I have written a user control which basically just creates a nic
themed box in the style of my site, the content for the control i
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 supporte
in this context". Is there any way of injecting server side code int
this section WITHOUT resorting to using the page_load method? I want t
be able to keep some of my code in the aspx file rather than the aspx.c
code-behind file.
Regards,
Anthony William

--
ant17
-----------------------------------------------------------------------
ant177's Profile: http://www.highdots.com/forums/m156
View this thread: http://www.highdots.com/forums/t63805

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Methods and blocks - not that clear when blocks passed into Steven Taylor Ruby 9 04-27-2009 08:46 AM
return HttpStatusCode.ServiceUnavailable in the context.context.Response.StatusCode (Http response code 503) Flip Rayner ASP .Net 1 01-23-2007 06:35 AM
Controls that contain code: Code Blocks Not Supported Microsoft ASP .Net Building Controls 1 12-14-2005 03:14 PM
procs/blocks - blocks with procs, blocks with blocks? matt Ruby 1 08-06-2004 01:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57