Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

<#% eval %> - possible?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 03 Oct 2007 18:57 GMT
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
Juan Romero - 03 Oct 2007 19:04 GMT
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.

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
Mike - 03 Oct 2007 19:10 GMT
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

>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
[quoted text clipped - 13 lines]
> to do this in a GridView that is using template fields with links in the
> fields
bruce barker - 03 Oct 2007 20:55 GMT
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)

> Is it possible to do this in the HTML of the aspx page?
>  
[quoted text clipped - 10 lines]
> to do this in a GridView that is using template fields with links in the
> fields
Mike - 04 Oct 2007 12:53 GMT
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 %>

> no. <%# %> is a binding expression and can only be used to specify a
> property value of a server control (prop="<%# expression%>"). also it must
[quoted text clipped - 16 lines]
>> to do this in a GridView that is using template fields with links in the
>> fields
George Ter-Saakov - 04 Oct 2007 15:33 GMT
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
 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
Mike - 04 Oct 2007 15:48 GMT
OK, I'll give it a shot, and see if it will show the correct image based on the value passed to the routine
 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" <Mike@community.nospam.com> wrote in message news:Olv0dbeBIHA.4476@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
George Ter-Saakov - 04 Oct 2007 16:00 GMT
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.

 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-nsp@cardone.com> wrote in message news:%23opuFOpBIHA.4496@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" <Mike@community.nospam.com> wrote in message news:Olv0dbeBIHA.4476@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
Mike - 04 Oct 2007 16:22 GMT
it worked for my scenario, thanks.

I'll keep that in mind for the future, thanks
 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" <Mike@community.nospam.com> wrote in message news:%23rMpyWpBIHA.1056@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-nsp@cardone.com> wrote in message news:%23opuFOpBIHA.4496@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" <Mike@community.nospam.com> wrote in message news:Olv0dbeBIHA.4476@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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.