473,395 Members | 1,931 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,395 software developers and data experts.

<#% eval %> - possible?

Is it possible to do this in the HTML of the aspx page?

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized, etc.

how can I get this to work without adding it to the code behind? I need to do this in a GridView that is using template fields with links in the fields
Oct 3 '07 #1
8 2666
I am not sure if this is possible but I recommend you avoid this style of
coding. Put all code in your code behind page so you have a clean separation
of layers.

"Mike" <Mi**@community.nospam.comwrote in message
news:Ol**************@TK2MSFTNGP06.phx.gbl...
Is it possible to do this in the HTML of the aspx page?

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized, etc.

how can I get this to work without adding it to the code behind? I need to
do this in a GridView that is using template fields with links in the fields
Oct 3 '07 #2
I would rather not do this either but the grid is binding to a dataset and I
really can't teak with that too much

"Juan Romero" <py**@hotmail.comwrote in message
news:eW**************@TK2MSFTNGP03.phx.gbl...
>I am not sure if this is possible but I recommend you avoid this style of
coding. Put all code in your code behind page so you have a clean
separation of layers.

"Mike" <Mi**@community.nospam.comwrote in message
news:Ol**************@TK2MSFTNGP06.phx.gbl...
Is it possible to do this in the HTML of the aspx page?

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized, etc.

how can I get this to work without adding it to the code behind? I need
to do this in a GridView that is using template fields with links in the
fields

Oct 3 '07 #3
no. <%# %is a binding expression and can only be used to specify a
property value of a server control (prop="<%# expression%>"). also it
must be an expression, not a statement.

you gave no sample of what you are trying to do, so its hard to give an
answer.
-- bruce (sqlwork.com)
Mike wrote:
Is it possible to do this in the HTML of the aspx page?

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized, etc.

how can I get this to work without adding it to the code behind? I need
to do this in a GridView that is using template fields with links in the
fields
Oct 3 '07 #4
you gave no sample of what you are trying to do, so its hard to give an
answer.
yeah I did: it was in my first post:

I need to show an particular image if the person exists in the db or not and
the developer that created this page is using a dataset to bind the grid but
in the html is using template fields and is using the <%# %for every
template field in the grid.

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
"bruce barker" <no****@nospam.comwrote in message
news:u0**************@TK2MSFTNGP05.phx.gbl...
no. <%# %is a binding expression and can only be used to specify a
property value of a server control (prop="<%# expression%>"). also it must
be an expression, not a statement.

you gave no sample of what you are trying to do, so its hard to give an
answer.
-- bruce (sqlwork.com)
Mike wrote:
>Is it possible to do this in the HTML of the aspx page?
<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized,
etc.
how can I get this to work without adding it to the code behind? I need
to do this in a GridView that is using template fields with links in the
fields

Oct 4 '07 #5
You will have to create your own function for that in a code behind

like
public string GetName(object objName)
{
if( objName == null )
return "No Name";
else
return (string)objName;
}

and call it

<%# GetName(Eval("Name")) %>
George
"Mike" <Mi**@community.nospam.comwrote in message news:Ol**************@TK2MSFTNGP06.phx.gbl...
Is it possible to do this in the HTML of the aspx page?

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized, etc.

how can I get this to work without adding it to the code behind? I need to do this in a GridView that is using template fields with links in the fields
Oct 4 '07 #6
OK, I'll give it a shot, and see if it will show the correct image based on the value passed to the routine
"George Ter-Saakov" <gt****@cardone.comwrote in message news:%2****************@TK2MSFTNGP06.phx.gbl...
You will have to create your own function for that in a code behind

like
public string GetName(object objName)
{
if( objName == null )
return "No Name";
else
return (string)objName;
}

and call it

<%# GetName(Eval("Name")) %>
George
"Mike" <Mi**@community.nospam.comwrote in message news:Ol**************@TK2MSFTNGP06.phx.gbl...
Is it possible to do this in the HTML of the aspx page?

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized, etc.

how can I get this to work without adding it to the code behind? I need to do this in a GridView that is using template fields with links in the fields
Oct 4 '07 #7
That is how I always do.

Also I usually put those type of functions into <script runat=server"on the aspx page itself rather than have them in .CS files
Since I think they relate to GUI. Except the cases when I need to have standardized output across web site.

I usually have static functions in my clsGlobal: OutputDate(), OutputMoney(). Thus I can switch my date format or currency in one place for every page pretty painlessly.


George.

"Mike" <Mi**@community.nospam.comwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
OK, I'll give it a shot, and see if it will show the correct image based on the value passed to the routine
"George Ter-Saakov" <gt****@cardone.comwrote in message news:%2****************@TK2MSFTNGP06.phx.gbl...
You will have to create your own function for that in a code behind

like
public string GetName(object objName)
{
if( objName == null )
return "No Name";
else
return (string)objName;
}

and call it

<%# GetName(Eval("Name")) %>
George
"Mike" <Mi**@community.nospam.comwrote in message news:Ol**************@TK2MSFTNGP06.phx.gbl...
Is it possible to do this in the HTML of the aspx page?

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized, etc.

how can I get this to work without adding it to the code behind? I need to do this in a GridView that is using template fields with links in the fields
Oct 4 '07 #8
it worked for my scenario, thanks.

I'll keep that in mind for the future, thanks
"George Ter-Saakov" <gt****@cardone.comwrote in message news:ea**************@TK2MSFTNGP03.phx.gbl...
That is how I always do.

Also I usually put those type of functions into <script runat=server"on the aspx page itself rather than have them in .CS files
Since I think they relate to GUI. Except the cases when I need to have standardized output across web site.

I usually have static functions in my clsGlobal: OutputDate(), OutputMoney(). Thus I can switch my date format or currency in one place for every page pretty painlessly.


George.

"Mike" <Mi**@community.nospam.comwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
OK, I'll give it a shot, and see if it will show the correct image based on the value passed to the routine
"George Ter-Saakov" <gt****@cardone.comwrote in message news:%2****************@TK2MSFTNGP06.phx.gbl...
You will have to create your own function for that in a code behind

like
public string GetName(object objName)
{
if( objName == null )
return "No Name";
else
return (string)objName;
}

and call it

<%# GetName(Eval("Name")) %>
George
"Mike" <Mi**@community.nospam.comwrote in message news:Ol**************@TK2MSFTNGP06.phx.gbl...
Is it possible to do this in the HTML of the aspx page?

<#% if Eval("Name") != null %>
write something here
<#% else %>
show message for missing name
<#% end if %>
when I try this I get errors for missing (, or IF is not recognized, etc.

how can I get this to work without adding it to the code behind? I need to do this in a GridView that is using template fields with links in the fields
Oct 4 '07 #9

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

Similar topics

4
by: A Web Master | last post by:
As a mean of not having to use Framesets/Frames with all the bad side effects/workarounds that come with them, I want to know if it is possible to code a scrolling veritcal bar into a table <TD> ?...
6
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with...
0
by: Stan Brown | last post by:
URL: http://www.acad.sunytccc.edu/instruct/sbrown/stat/mygrades.htm As I read the spec, I need _either_ data= and type= _or_ classid= and codetype=. I've tried it both ways and neither works. I...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
21
by: hemant.singh | last post by:
Hello all, I am try'g to send window.location.href to the server script who will generate dynamic javascript according to the referral name comg in as param Now bcz <script language="javascript"...
0
by: maxnospam | last post by:
I am using the <secureWebPages> feature, part of the Hyper.Web.Security page to designate pages that should be accessed over SSL. I have a couple of websites that each get accessed from different...
4
by: thaytu888888 | last post by:
Here is my codes in aspx page: <td colspan="2" class="main_menu" runat="server" onclick='toggleDisplay(<%#Eval("description")%>);'><%#Eval("description")%></td> Here is in "View source": ...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...

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.