Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Valid Date - << C# VERSION >>

Validate a string as DateTime


<%@ Page Language="vb" %>
<%@ Import Namespace="System.Globalization" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<script runat="server">
Private Sub btnValidate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  Try
    Dim myDateTime As System.DateTime
    Dim format As New System.Globalization.CultureInfo("it-IT", True)
    myDateTime = System.DateTime.Parse(txtDate.Text, format)
    lbControllo.Text = "valida"
    Catch ex As Exception
      lbControllo.Text = "<span style='white-space:nowrap'>Errore: " & ex.Message & "</span>"
    End Try
End Sub
</script>
<body>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="275" border="0" style="WIDTH: 275px; HEIGHT: 25px">
<TR>
  <TD style="WIDTH: 109px"><asp:Label id="Label1" runat="server">Inserisci una data</asp:Label></TD>
  <TD><asp:TextBox id="txtDate" runat="server"></asp:TextBox></TD>
</TR>
<TR>
  <TD style="WIDTH: 109px"></TD>
  <TD><asp:button id="btnValidate" runat="server" Text="Controlla" OnClick="btnValidate_Click"></asp:button></TD>
</TR>
</TABLE>
<BR>
<asp:Label id="lbControllo" runat="server"></asp:Label></form>
</form>
</body>
</HTML>



Download Code...


Print Page


 


Page top

risorse per webmaster