PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

DateTimeFormat

 
 
gh
Guest
Posts: n/a
 
      1st Oct 2007
I am trying to format a datetime in a datalist label. Below is the aspx
code I have, but I get an error: The name 'Format' does not exist in the
current context.

How do I format the datetime to display the date portion only in the label.

TIA


<asp:Label id="ProjectDateLabel" runat="server"
text='<%#Format(Eval("ProjectDate"),"d/M/yyyy")%>'></asp:Label>Address:
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      1st Oct 2007
On Oct 1, 6:57 pm, gh <g...@att.net> wrote:
> I am trying to format a datetime in a datalist label. Below is the aspx
> code I have, but I get an error: The name 'Format' does not exist in the
> current context.
>
> How do I format the datetime to display the date portion only in the label.
>
> TIA
>
> <asp:Label id="ProjectDateLabel" runat="server"
> text='<%#Format(Eval("ProjectDate"),"d/M/yyyy")%>'></asp:Label>Address:


C#?

Try string.Format

 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      1st Oct 2007
Try this
<%# DataBinder.Eval(Container.DataItem, "ProjectDate", "{0:dd/MM/yyyy}") %>

Or my guess <%# Eval("ProjectDate", "{0:dd/MM/yyyy}") %> (never worked with
that, awlays used DataBinder object)

George





"gh" <(E-Mail Removed)> wrote in message
news:OL8%(E-Mail Removed)...
>I am trying to format a datetime in a datalist label. Below is the aspx
>code I have, but I get an error: The name 'Format' does not exist in the
>current context.
>
> How do I format the datetime to display the date portion only in the
> label.
>
> TIA
>
>
> <asp:Label id="ProjectDateLabel" runat="server"
> text='<%#Format(Eval("ProjectDate"),"d/M/yyyy")%>'></asp:Label>Address:



 
Reply With Quote
 
gh
Guest
Posts: n/a
 
      1st Oct 2007
George Ter-Saakov wrote:
> Try this
> <%# DataBinder.Eval(Container.DataItem, "ProjectDate", "{0:dd/MM/yyyy}") %>
>
> Or my guess <%# Eval("ProjectDate", "{0:dd/MM/yyyy}") %> (never worked with
> that, awlays used DataBinder object)
>
> George
>
>
>
>
>
> "gh" <(E-Mail Removed)> wrote in message
> news:OL8%(E-Mail Removed)...
>
>>I am trying to format a datetime in a datalist label. Below is the aspx
>>code I have, but I get an error: The name 'Format' does not exist in the
>>current context.
>>
>>How do I format the datetime to display the date portion only in the
>>label.
>>
>>TIA
>>
>>
>> <asp:Label id="ProjectDateLabel" runat="server"
>>text='<%#Format(Eval("ProjectDate"),"d/M/yyyy")%>'></asp:Label>Address:

>
>
>

George:

That did it. Do you by chance know how to make an image a hyper link?
Below is the code I have.

<asp:Image id="Image1" runat="server" height="125px" width="125px"
imagealign="Left" imageurl='<%# "images/" +
DataBinder.Eval(Container.DataItem, "PHOTOID")%>'></asp:image>&nbsp;PhotoID:

TIA
 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      1st Oct 2007
Do not try to make everything as a Server control. Usually image should not
be a server control.

Do something like this
<a href="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>" >
<img src="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>"
height="125px" width="125px" >
</a>

PS: Nothing prevents you from making it as a server control and use
<asp:Image> <asp:Link>. You will just consume more resources if you are not
using them as a server controls.

George.

> Do you by chance know how to make an image a hyper link? Below is the code
> I have.
>
> <asp:Image id="Image1" runat="server" height="125px" width="125px"
> imagealign="Left" imageurl='<%# "images/" +
> DataBinder.Eval(Container.DataItem,
> "PHOTOID")%>'></asp:image>&nbsp;PhotoID:
>
> TIA



 
Reply With Quote
 
gh
Guest
Posts: n/a
 
      2nd Oct 2007
George Ter-Saakov wrote:

> Do not try to make everything as a Server control. Usually image should not
> be a server control.
>
> Do something like this
> <a href="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>" >
> <img src="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>"
> height="125px" width="125px" >
> </a>
>
> PS: Nothing prevents you from making it as a server control and use
> <asp:Image> <asp:Link>. You will just consume more resources if you are not
> using them as a server controls.
>
> George.
>
>
>>Do you by chance know how to make an image a hyper link? Below is the code
>>I have.
>>
>> <asp:Image id="Image1" runat="server" height="125px" width="125px"
>>imagealign="Left" imageurl='<%# "images/" +
>>DataBinder.Eval(Container.DataItem,
>>"PHOTOID")%>'></asp:image>&nbsp;PhotoID:
>>
>>TIA

>
>
>

George:

When the image is clicked I have a value of anther field I need to pass
in the url. I use the code below in a link to do this and it works
great. Can this be done without using runat server? Anyway the


<asp:HyperLink runat="server" navigateurl='<%#"selphotos.aspx?id="+
DataBinder.Eval(Container.DataItem, "ExternalId").ToString()%>'
id="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,
"PrjID")%></asp:HyperLink>

What I was trying was to use the code below with the image, but it
doesn' t act as a link, when clicked.

<asp:HyperLink><asp:Image id="Image1" runat="server" height="125px"
width="125px"
imagealign="Left" runat="server" navigateurl='<%#"selphotos.aspx?id="+
DataBinder.Eval(Container.DataItem, "ExternalId").ToString()%>'
id="Hyperlink1"><%# "images/" +
DataBinder.Eval(Container.DataItem,"PHOTOID")%>'></asp:image></asp:HyperLink>

TIA

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      2nd Oct 2007
On Oct 2, 2:24 am, gh <g...@att.net> wrote:
> George Ter-Saakov wrote:
> > Do not try to make everything as a Server control. Usually image shouldnot
> > be a server control.

>
> > Do something like this
> > <a href="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>">
> > <img src="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>"
> > height="125px" width="125px" >
> > </a>

>
> > PS: Nothing prevents you from making it as a server control and use
> > <asp:Image> <asp:Link>. You will just consume more resources if you arenot
> > using them as a server controls.

>
> > George.

>
> >>Do you by chance know how to make an image a hyper link? Below is the code
> >>I have.

>
> >> <asp:Image id="Image1" runat="server" height="125px" width="125px"
> >>imagealign="Left" imageurl='<%# "images/" +
> >>DataBinder.Eval(Container.DataItem,
> >>"PHOTOID")%>'></asp:image>&nbsp;PhotoID:

>
> >>TIA

>
> George:
>
> When the image is clicked I have a value of anther field I need to pass
> in the url. I use the code below in a link to do this and it works
> great. Can this be done without using runat server? Anyway the
>
> <asp:HyperLink runat="server" navigateurl='<%#"selphotos.aspx?id="+
> DataBinder.Eval(Container.DataItem, "ExternalId").ToString()%>'
> id="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,
> "PrjID")%></asp:HyperLink>
>
> What I was trying was to use the code below with the image, but it
> doesn' t act as a link, when clicked.
>
> <asp:HyperLink><asp:Image id="Image1" runat="server" height="125px"
> width="125px"
> imagealign="Left" runat="server" navigateurl='<%#"selphotos.aspx?id="+
> DataBinder.Eval(Container.DataItem, "ExternalId").ToString()%>'
> id="Hyperlink1"><%# "images/" +
> DataBinder.Eval(Container.DataItem,"PHOTOID")%>'></asp:image></asp:HyperLin*k>
>
> TIA- Hide quoted text -
>
> - Show quoted text -


An image with a hyper link on html page can be created using a mix of
<a> and <img> tags. In ASP.NET, the <img> tag is rendered through the
Image control and <a> through the HyperLink. Note, neither <img> nor
Image control has a destination link property (navigateurl in your
case).

There is another control, named ImageButton, take a look, maybe this
helps
http://samples.gotdotnet.com/quickst..._imagebut.aspx

..NET server control cannot work without runat=server.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DateTimeFormat.MonthNames contains 13 items??? Jesse Houwing Microsoft Dot NET Framework 5 25th Feb 2010 03:01 PM
DateTimeFormat issue in schema.ini file Radu Stanciu Microsoft Access External Data 2 29th Mar 2005 05:25 PM
WebApplication - CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern--Not Working!! Muralidhar Chennoju Microsoft C# .NET 0 6th Oct 2004 05:28 PM
DateTimeFormat Karunakararao Microsoft C# .NET 4 30th Sep 2004 01:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:58 AM.