Having trouble inserting date value into the database

Last post 06-24-2005 9:46 AM by midwestern_developer. 4 replies.

Sort Posts:

  • Having trouble inserting date value into the database

    06-23-2005, 1:51 PM
    • Member
      10 point Member
    • fatz1
    • Member since 06-23-2005, 5:48 PM
    • Posts 2
    Here is my code


     <tr>
          <td align="right" valign="top" ><B>Date: </B></TD>
          <TD valign="top"><Input class="text3" input type="text" maxLength="12" id="txteffdt" name="date1" size="9" value="<%= FormatDateTime(now(),2)%>">
          <A href="javascript:ShowCalendar(document.myForm.dateimg1,document.myForm.date1,null, '<%= FormatDateTime(DateAdd("yyyy", -1, now()),2)%>', '<%= FormatDateTime(DateAdd("yyyy", 1, now()),2)%>')" onclick=event.cancelBubble=true;>
          <IMG align=top border=0 height=21 id=dateimg1 src="cal/calendar.gif" style="POSITION: relative" width=34></A></td>
      </tr>

    oCom17.Parameters.Add("@txteffdt", system.Data.SqlDbType.datetime, 12).value = txteffdt.value

    I get this error message:
    BC30456: 'value' is not a member of 'System.Web.UI.WebControls.TextBox'.

    This error msg is with text or value
  • Re: Having trouble inserting date value into the database

    06-23-2005, 2:49 PM
    • Contributor
      5,430 point Contributor
    • Optik
    • Member since 04-01-2003, 9:21 AM
    • USA
    • Posts 1,102
    You can't access properties of html controls without adding the runat="server" attribute to them.  Either add that to the input tag or use an asp:textbox control instead.
    In this world there are 10 types of people, those that know binary and those who don't.
  • Re: Having trouble inserting date value into the database

    06-24-2005, 8:36 AM
    • Member
      10 point Member
    • fatz1
    • Member since 06-23-2005, 5:48 PM
    • Posts 2
    When I add the runat="server" to the input tag the date popup calander locks up.

    The input value on the form will show <%=FormatDateTime(now(),2)%> instead of the value 06/21/2005 that I receive without runat="server"
     
  • Re: Having trouble inserting date value into the database

    06-24-2005, 8:58 AM
    • Member
      230 point Member
    • govmk
    • Member since 12-29-2003, 6:12 PM
    • Posts 49

    use
    Request.Form("TextBoxID")  --> in VB.NET
    or
    Request.Params("TextBoxID")  --> in C#

    in codebehind to get the value of the input textbox. 
    "TextBoxID" is the id generated for textbox in HTML (View source in the broswer)


  • Re: Having trouble inserting date value into the database

    06-24-2005, 9:46 AM
    try replacing the inline code  <%=FormatDateTime(now(),2)%> with adding runat=server to the textbox and initializing the the  textbox value in the page_load event  txteffdt.text =FormatDateTime(now(),2)  
Page 1 of 1 (5 items)