473,320 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Server tags cannot contain <% ... %> constructs

Hi,

I've put a appSetting tag into my web.config, but when I try to catch its
value to my Image WebControl occurs the follow error: "Server tags cannot
contain <% ... %> constructs."

on myPage.aspx (Notice the ImageUrl tag):
<asp:Image id="Image1" runat="server"
ImageUrl=<%=System.Configuration.ConfigurationSett ings.AppSettings["SrcImgSi
stema"]%> />

So, What's wrong with my ImageUrl attribution?
Is there any way to do that?

thanks a lot
Marcos
Nov 18 '05 #1
6 47590
you can set this property programmatically within a server script block:
Image1.ImageUrl =
System.Configuration.ConfigurationSettings.AppSett ings.....
you cannot use <%%> inside a web control as web controls already run at the
server.
sharon.

"Marcos MOS" <ma***********@softway.com.br> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,

I've put a appSetting tag into my web.config, but when I try to catch its
value to my Image WebControl occurs the follow error: "Server tags cannot
contain <% ... %> constructs."

on myPage.aspx (Notice the ImageUrl tag):
<asp:Image id="Image1" runat="server"
ImageUrl=<%=System.Configuration.ConfigurationSett ings.AppSettings["SrcImgSi stema"]%> />

So, What's wrong with my ImageUrl attribution?
Is there any way to do that?

thanks a lot
Marcos

Nov 18 '05 #2
Thanks... but, I'd like to do it inside my .aspx file...

Isn't it possible?

tanks
Marcos

"Sharon" <ta*******@hotmail.com> escreveu na mensagem
news:Ov**************@TK2MSFTNGP10.phx.gbl...
you can set this property programmatically within a server script block:
Image1.ImageUrl =
System.Configuration.ConfigurationSettings.AppSett ings.....
you cannot use <%%> inside a web control as web controls already run at the server.
sharon.

"Marcos MOS" <ma***********@softway.com.br> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,

I've put a appSetting tag into my web.config, but when I try to catch its value to my Image WebControl occurs the follow error: "Server tags cannot contain <% ... %> constructs."

on myPage.aspx (Notice the ImageUrl tag):
<asp:Image id="Image1" runat="server"

ImageUrl=<%=System.Configuration.ConfigurationSett ings.AppSettings["SrcImgSi
stema"]%> />

So, What's wrong with my ImageUrl attribution?
Is there any way to do that?

thanks a lot
Marcos


Nov 18 '05 #3
i don't know of any way, and there is no reason to do it inside the html
section.
one of the ideas behind web controls design, is the separation of code from
html.

"Marcos MOS" <ma***********@softway.com.br> wrote in message
news:e0*************@TK2MSFTNGP11.phx.gbl...
Thanks... but, I'd like to do it inside my .aspx file...

Isn't it possible?

tanks
Marcos

"Sharon" <ta*******@hotmail.com> escreveu na mensagem
news:Ov**************@TK2MSFTNGP10.phx.gbl...
you can set this property programmatically within a server script block:
Image1.ImageUrl =
System.Configuration.ConfigurationSettings.AppSett ings.....
you cannot use <%%> inside a web control as web controls already run at

the
server.
sharon.

"Marcos MOS" <ma***********@softway.com.br> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,

I've put a appSetting tag into my web.config, but when I try to catch its value to my Image WebControl occurs the follow error: "Server tags cannot contain <% ... %> constructs."

on myPage.aspx (Notice the ImageUrl tag):
<asp:Image id="Image1" runat="server"

ImageUrl=<%=System.Configuration.ConfigurationSett ings.AppSettings["SrcImgSi
stema"]%> />

So, What's wrong with my ImageUrl attribution?
Is there any way to do that?

thanks a lot
Marcos



Nov 18 '05 #4
use the binding syntax <%# bindingexpression %>

-- bruce (sqlwork.com)
"Marcos MOS" <ma***********@softway.com.br> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,

I've put a appSetting tag into my web.config, but when I try to catch its
value to my Image WebControl occurs the follow error: "Server tags cannot
contain <% ... %> constructs."

on myPage.aspx (Notice the ImageUrl tag):
<asp:Image id="Image1" runat="server"
ImageUrl=<%=System.Configuration.ConfigurationSett ings.AppSettings["SrcImgSi stema"]%> />

So, What's wrong with my ImageUrl attribution?
Is there any way to do that?

thanks a lot
Marcos

Nov 18 '05 #5
In your code there are some errors :

The <%= construct can only be used in client script for write some value
from server (like old ASP).
your Image is server side not in client side!!!!

You can use the <%# construct. This is for binding value!
<asp:Image id="Image1" runat="server"
ImageUrl='<%#System.Configuration.ConfigurationSet tings.AppSettings["SrcImgS
istema"]%>' />

this code require a DataBind() method call!!!

Brun
"Marcos MOS" <ma***********@softway.com.br> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,

I've put a appSetting tag into my web.config, but when I try to catch its
value to my Image WebControl occurs the follow error: "Server tags cannot
contain <% ... %> constructs."

on myPage.aspx (Notice the ImageUrl tag):
<asp:Image id="Image1" runat="server"
ImageUrl=<%=System.Configuration.ConfigurationSett ings.AppSettings["SrcImgSi stema"]%> />

So, What's wrong with my ImageUrl attribution?
Is there any way to do that?

thanks a lot
Marcos

Nov 18 '05 #6
In your code there are some errors :

The <%= construct can only be used in client script for write some value
from server (like old ASP).
your Image is server side not in client side!!!!

You can use the <%# construct. This is for binding value!
<asp:Image id="Image1" runat="server"
ImageUrl='<%#System.Configuration.ConfigurationSet tings.AppSettings["SrcImgS
istema"]%>' />

this code require a DataBind() method call!!!

Brun


"Marcos MOS" <marcos.santos@softway.com.br> wrote in message
news:ulbiAAmIEHA.3240@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi,
>
> I've put a appSetting tag into my web.config, but when I try to catch its
> value to my Image WebControl occurs the follow error: "Server tags cannot
> contain <% ... %> constructs."
>
> on myPage.aspx (Notice the ImageUrl tag):
> <asp:Image id="Image1" runat="server"
>[/color]
ImageUrl=<%=System.Configuration.ConfigurationSett ings.AppSettings["SrcImgSi[color=blue]
> stema"]%> />
>
> So, What's wrong with my ImageUrl attribution?
> Is there any way to do that?
>
> thanks a lot
> Marcos
>
>[/color]
In ASP.NET 2.0 not only can you refer to appSettings declaratively (without using the DataBinding syntax), which is precisely what you are trying to do here, but you can create an ExpressionBuilder that lets you run arbitrary code declaratively, which is precisely what you tried to do. Check it out here: http://infinitiesloop.blogspot.com/
Apr 27 '06 #7

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

Similar topics

4
by: | last post by:
Hello, We upgraded to Windows Small Business Server 2003 It seems that there is something changed with the asp INCLUDE statement. here is my code: <!--#include file="../_includes/common.asp"...
5
by: Marcos MOS | last post by:
Hi, I've put a appSetting tag into my web.config, but when I try to catch its value to my Image WebControl occurs the follow error: "Server tags cannot contain <% ... %> constructs." on...
1
by: Martin Schmid | last post by:
I'm getting a parser error message: Server tags cannot contain <% ... %> constructs... Ok.. so How do I accomplish this: For Each file in Files if ucase(right(file.name,7))<>ucase("_tn.jpg")...
3
by: Julie | last post by:
I've got one that I've spent all to much time on: I have an aspx page that includes the following (code behind is C#): <asp:Imagebutton runat="server" ImageUrl='<%# Application +...
1
by: Neil Zanella | last post by:
Hello, I would like to do the following: <form method="post" action="<%= Request.ServerVariables %>" runat="server"> The reason I would like to do this is twofold:
4
by: michaeltorus | last post by:
Do server Side tags decrease performance ... i.e. Does it make any difference from <% response.write "A" % <% response.write "B" % <% response.write "C" % <% response.write "D" % t
2
by: =?Utf-8?B?Sm9zaCBOaWtsZQ==?= | last post by:
I hope someone can help with this, because it’s driving me crazy. It’s also a little tough to describe what’s happening, but I’ll do my best. I have a class that takes a ProductID and...
3
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.