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

Home Posts Topics Members FAQ

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 47612
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
InfintiesLoop
1 New Member
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
3783
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
628
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
1920
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
1343
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
3313
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
1155
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
1392
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
3344
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
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
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.