473,549 Members | 2,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<#% 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 2672
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.comwrot e in message
news:Ol******** ******@TK2MSFTN GP06.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.c omwrote in message
news:eW******** ******@TK2MSFTN GP03.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.comwrot e in message
news:Ol******** ******@TK2MSFTN GP06.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******** ******@TK2MSFTN GP05.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("N ame")) %>
George
"Mike" <Mi**@community .nospam.comwrot e in message news:Ol******** ******@TK2MSFTN GP06.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******** ********@TK2MSF TNGP06.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("N ame")) %>
George
"Mike" <Mi**@community .nospam.comwrot e in message news:Ol******** ******@TK2MSFTN GP06.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.comwrot e in message news:%2******** ********@TK2MSF TNGP03.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******** ********@TK2MSF TNGP06.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("N ame")) %>
George
"Mike" <Mi**@community .nospam.comwrot e in message news:Ol******** ******@TK2MSFTN GP06.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******** ******@TK2MSFTN GP03.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.comwrot e in message news:%2******** ********@TK2MSF TNGP03.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******** ********@TK2MSF TNGP06.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("N ame")) %>
George
"Mike" <Mi**@community .nospam.comwrot e in message news:Ol******** ******@TK2MSFTN GP06.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
3560
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> ? If so, how ? I am coding my client's WEB site in ASP.
6
12142
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 you and see if there are any improvments that i should make ;-) It should be fast and if possible compatible with todays modern browser-standards. It...
0
5345
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 googled, but was overwhelmed with results and none of them seemed hopeful (probably because I don't see how to frame a query specifically enough). ...
11
13664
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, there's an "Edit" link. So the page itself looks something like this: <HTML><HEAD><TITLE>blah</TITLE></HEAD><BODY> <!-- TEXT STARTS HERE --> ...
7
2734
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 tags will remain making the page safe (I have to convert the linefeeds to <BR>s because the Server.EncodeHTML does not do that it seems). The...
21
8503
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" src="NO JAVASCRIPT CAN BE USED HERE" /> So I am see'g If I can use eval todo something what I am doing I have tried almost everything,...
0
1387
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 ports Site 1 - Reg. Port - 25001, Secure Port - 26001 Site 2 - Reg. Port - 25002, Secure Port - 26002 etc... With that in place, I cannot get...
4
4195
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": onclick="toggleDisplay(&lt;%#Eval(&quot;description&quot;)%>);">Administrator Functions</td> When putting <%#Eval('description')%> in <td> tag, it understand & show...
4
11898
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> </myXml> I there a way that the XSLT transformation can render the content as html rather than text?
0
7446
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7718
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. ...
0
7956
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...
1
7470
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...
0
7809
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...
0
6041
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1936
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
1
1058
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.