473,809 Members | 2,849 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=<%=Sys tem.Configurati on.Configuratio nSettings.AppSe ttings["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 47656
you can set this property programmaticall y within a server script block:
Image1.ImageUrl =
System.Configur ation.Configura tionSettings.Ap pSettings.....
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******** ******@TK2MSFTN GP12.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=<%=Sys tem.Configurati on.Configuratio nSettings.AppSe ttings["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*******@hotm ail.com> escreveu na mensagem
news:Ov******** ******@TK2MSFTN GP10.phx.gbl...
you can set this property programmaticall y within a server script block:
Image1.ImageUrl =
System.Configur ation.Configura tionSettings.Ap pSettings.....
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******** ******@TK2MSFTN GP12.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=<%=Sys tem.Configurati on.Configuratio nSettings.AppSe ttings["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******** *****@TK2MSFTNG P11.phx.gbl...
Thanks... but, I'd like to do it inside my .aspx file...

Isn't it possible?

tanks
Marcos

"Sharon" <ta*******@hotm ail.com> escreveu na mensagem
news:Ov******** ******@TK2MSFTN GP10.phx.gbl...
you can set this property programmaticall y within a server script block:
Image1.ImageUrl =
System.Configur ation.Configura tionSettings.Ap pSettings.....
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******** ******@TK2MSFTN GP12.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=<%=Sys tem.Configurati on.Configuratio nSettings.AppSe ttings["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 <%# bindingexpressi on %>

-- bruce (sqlwork.com)
"Marcos MOS" <ma***********@ softway.com.br> wrote in message
news:ul******** ******@TK2MSFTN GP12.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=<%=Sys tem.Configurati on.Configuratio nSettings.AppSe ttings["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='<%#Sy stem.Configurat ion.Configurati onSettings.AppS ettings["SrcImgS
istema"]%>' />

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

Brun
"Marcos MOS" <ma***********@ softway.com.br> wrote in message
news:ul******** ******@TK2MSFTN GP12.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=<%=Sys tem.Configurati on.Configuratio nSettings.AppSe ttings["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='<%#Sy stem.Configurat ion.Configurati onSettings.AppS ettings["SrcImgS
istema"]%>' />

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

Brun


"Marcos MOS" <marcos.santos@ softway.com.br> wrote in message
news:ulbiAAmIEH A.3240@TK2MSFTN GP12.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=<%=Sys tem.Configurati on.Configuratio nSettings.AppSe ttings["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 ExpressionBuild er 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
3806
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" --> and the error: Active Server Pages error 'ASP 0131' Disallowed Parent Path
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 myPage.aspx (Notice the ImageUrl tag): <asp:Image id="Image1" runat="server" ImageUrl=<%=System.Configuration.ConfigurationSettings.AppSettings%> />
1
1934
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") and ucase(right(file.name,4))=ucase(".jpg") then tnName=left(file.name,len(file.name)-4) & "_tn.jpg"%> <asp:imagebutton runat="server" ImageUrl=<%=tnName%> onClick="IB_Click"/>
3
1360
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 + "/images/up.gif" %>' /> When rendered, the image src tag isn't there (at all!). If I change to:
1
3364
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
1166
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
1408
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 then uses it to generate some html. I then insert that HTML into my page via server tags. I’m using a datalist for the content, making a 3 x 3 grid. For each instance of my ItemTemplate, I’m changing a pic, some text, a link button, and my...
3
3390
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, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above functionality without having to use &gt,&lt and such stuff???
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10643
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10378
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10391
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
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 we have to send another system
3
3015
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.