Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/03/2011, 15:17
Avatar de freesoftwarrior
freesoftwarrior
 
Fecha de Ingreso: marzo-2006
Mensajes: 362
Antigüedad: 18 años, 2 meses
Puntos: 10
Respuesta: Dudas sobre DateTime.ToString()

Muchas gracias por la respuesta.

Mira este es el código que tengo en Windows Live Writer, en uno de sus plugins

titulo, url01, web y url02 son campos texto, fecha es un campo Date/Time (me muestra calendario y la hora también al momento de ingresar el dato)

Código:
<%
DateTime dt = DateTime.Parse("fecha");
%>
<%= dt.ToLongDateString()%>

<li style="border-bottom:1px solid navy;">
<a href="<%=url01%>" target="_blank"><%=titulo%></a><br>
<font size="1">
&nbsp;&nbsp;&nbsp;Publicado en <a href="<%=url02%>" target="_blank"><%=web%></a><br>
&nbsp;&nbsp;&nbsp;agregado el <%=DateTime.Now.ToString("f")%>
</font>

y este el error que me muestra

Código:
System.Reflection.TargetInvocationException: Se produjo una excepción en el destino de la invocación. ---> System.FormatException: La cadena no se reconoce como DateTime válido. Hay una palabra desconocida al inicio del índice 0.
   en System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   en System.DateTime.Parse(String s)
   en Template.Process(Object state, Object[] parameters)
   --- Fin del seguimiento de la pila de la excepción interna ---
   en System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   en System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   en DynamicTemplate.Compiler.CSharpLanguageProvider.InvokeAdapter.Invoke(Object state, Object[] values)
   en DynamicTemplate.DynamicTemplateContentSource.CreateContent(IWin32Window dialogOwner, String& newContent)
   en WindowsLive.Writer.PostEditor.ContentSources.ContentSourceManager.PerformInsertion(IContentSourceSite sourceSite, ContentSourceInfo contentSource)

Lo que busco es ingresar la fecha (no tanto la hora) en que la noticia que estoy publicando, ha sido publicada en la fuente original.

Todo esto esta en NET y yo sólo conozco ASP clásico.

Mil gracias por tu ayuda en verdad.

Un saludo desde Lima, Perú

Última edición por freesoftwarrior; 30/03/2011 a las 01:34