Monday, March 26, 2012

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.ConfigurationSettings.AppSettings["SrcI
mgSi
stema"]%> />
So, What's wrong with my ImageUrl attribution?
Is there any way to do that?
thanks a lot
Marcosyou can set this property programmatically within a server script block:
Image1.ImageUrl =
System.Configuration.ConfigurationSettings.AppSettings....
you cannot use <%%> inside a web control as web controls already run at the
server.
sharon.
"Marcos MOS" <marcos.santos@.softway.com.br> wrote in message
news:ulbiAAmIEHA.3240@.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.ConfigurationSettings.AppSettings["SrcImgSired">
> stema"]%> />
> So, What's wrong with my ImageUrl attribution?
> Is there any way to do that?
> thanks a lot
> Marcos
>
Thanks... but, I'd like to do it inside my .aspx file...
Isn't it possible?
tanks
Marcos
"Sharon" <talsharon@.hotmail.com> escreveu na mensagem
news:OvBFDJmIEHA.3128@.TK2MSFTNGP10.phx.gbl...
> you can set this property programmatically within a server script block:
> Image1.ImageUrl =
> System.Configuration.ConfigurationSettings.AppSettings....
> you cannot use <%%> inside a web control as web controls already run at
the
> server.
> sharon.
> "Marcos MOS" <marcos.santos@.softway.com.br> wrote in message
> news:ulbiAAmIEHA.3240@.TK2MSFTNGP12.phx.gbl...
its
cannot
>
ImageUrl=<%=System.Configuration.ConfigurationSettings.AppSettings["SrcImgSired">
>
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" <marcos.santos@.softway.com.br> wrote in message
news:e0ARXWmIEHA.364@.TK2MSFTNGP11.phx.gbl...
> Thanks... but, I'd like to do it inside my .aspx file...
> Isn't it possible?
> tanks
> Marcos
> "Sharon" <talsharon@.hotmail.com> escreveu na mensagem
> news:OvBFDJmIEHA.3128@.TK2MSFTNGP10.phx.gbl...
> the
> its
> cannot
>
ImageUrl=<%=System.Configuration.ConfigurationSettings.AppSettings["SrcImgSired">
>
use the binding syntax <%# bindingexpression %>
-- bruce (sqlwork.com)
"Marcos MOS" <marcos.santos@.softway.com.br> wrote in message
news:ulbiAAmIEHA.3240@.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.ConfigurationSettings.AppSettings["SrcImgSired">
> stema"]%> />
> So, What's wrong with my ImageUrl attribution?
> Is there any way to do that?
> thanks a lot
> Marcos
>
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.ConfigurationSettings.AppSettings["Src
ImgS
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...
> 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["SrcImgSired">
> stema"]%> />
> So, What's wrong with my ImageUrl attribution?
> Is there any way to do that?
> thanks a lot
> Marcos
>

No comments:

Post a Comment