Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7799407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:17:56+00:00 2026-06-02T00:17:56+00:00

I have a web form that uses an Ajax date calendar. This works fine.

  • 0

I have a web form that uses an Ajax date calendar. This works fine. The problem that i have is that when i submit my form i get the following message.

'String value can not be converted to a date' .AgendaDate = New SmartDate(txtAgendaDate.Text)

Here is my web form that holds the calendar and the associated text box…

 <td>
     <asp:TextBox ID="txtAgendaDate" runat="server" ForeColor="Black" ></asp:TextBox>
 </td>
 <td>
     <asp:ImageButton runat="Server" ID="ImageButton1" ImageUrl="~/images/calendarpic.png" 
                AlternateText="Click here to display calendar" />

     <cc1:calendarextender ID="CalendarExtender1" runat="server" 
                     TargetControlID="txtAgendaDate" PopupButtonID="ImageButton1" >
     </cc1:calendarextender>
 </td>

I have a class with the associated properties on it for the web form. The rest of the fields work and submit data to the database except the textfield for the ajax calendar.

Here is my stripped down version for the code for the class and the txtAgendaDate code…

#Region " Agenda Variables "

'Declare Variables and data types and set default values
Private mAgendaID As Integer = 0
Private mOrganiser As String = ""
Private mMeeting As String = ""
Private mAgendaDate As SmartDate = New SmartDate()

#End Region

#Region " Constructors "

Public Sub New()
End Sub

Public Sub New(ByVal reader As SafeDataReader)
    '  Public Sub New(ByVal reader As SQLDataReader)

    'Combine variables & property types
    With reader
        mAgendaID = .GetInt32("AgendaID")
        mOrganiser = .GetString("Organiser")
        mMeeting = .GetString("Meeting")
        mAgendaDate = .GetSmartDate("AgendaDate")
    End With
End Sub

#End Region

#Region "Properties"

'Define form field properies so that they can be used when adding the data to the database on the add button is pressed.
Public Property AgendaID() As Integer
    Get
        Return mAgendaID
    End Get
    Set(ByVal Value As Integer)
        mAgendaID = Value
    End Set
End Property

Public Property Organiser() As String
    Get
        Return mOrganiser
    End Get
    Set(ByVal value As String)
        mOrganiser = value
    End Set
End Property

Public Property Meeting() As String
    Get
        Return mMeeting
    End Get
    Set(ByVal value As String)
        mMeeting = value
    End Set
End Property

Public Property AgendaDate() As SmartDate
    Get
        Return mAgendaDate
    End Get
    Set(ByVal Value As SmartDate)
        mAgendaDate = Value
    End Set
End Property

#End Region


End Class

Here is my command that looks connects to the DB and at the stored procedure and also has the parameters.

Public Class Agenda_TempDAL

Public Shared Function AddAgenda_Temp(ByVal Agenda_Temp As Agenda_Temp) As Integer

    'Declare i as integer as 0
    Dim iAgendaID As Integer = 0

    'Database conn, this is linked to the web config file .AppSettings
    Using dbconnection As New SqlConnection(ConfigurationManager.AppSettings("dbconnection"))
        dbconnection.Open()

        'Command to state the stored procedure and the name of the stored procedure
        Using dbcommand As SqlCommand = dbconnection.CreateCommand
            With dbcommand
                .CommandType = CommandType.StoredProcedure
                .CommandText = "Stored_Proc_Name"

                'Create parameter for AgendaID and output
                Dim oParam As New SqlParameter
                oParam.ParameterName = "@AgendaID"
                oParam.Direction = ParameterDirection.Output
                oParam.SqlDbType = SqlDbType.Int

                'Create parameters for the remaining fields
                .Parameters.Add(oParam)
                .Parameters.AddWithValue("@Organiser", Agenda_Temp.Organiser)
                .Parameters.AddWithValue("@Meeting", Agenda_Temp.Meeting)
                .Parameters.AddWithValue("@AgendaDate", Agenda_Temp.AgendaDate.DBValue)

                'Simply execute the query
                dbcommand.ExecuteNonQuery()

            End With
        End Using
    End Using

    'Need to return the agendaID as an integer.
    Return iAgendaID

End Function
End Class 

And here is the code behind the button ion the web page. This is the page that causes the error based on the property / field. The problem lies on this line…

.AgendaDate = New SmartDate(txtAgendaDate.Text)

The whole code for the button is here…

Protected Sub btnAddAgendaTemplate_Click(ByVal sender As Object, ByVal e As    System.EventArgs) Handles btnAddAgendaTemplate.Click

    'This works alongside the Class named Agenda_Temp which has the properties and DB connection assigned to it for each web form field.
    Dim oAgenda_Temp As New Agenda_Temp

    'Within the object Agenda_Temp Class use the properties defined. 
    'They are required to be defined in the Agenda_Temp/ app code so we can use them within here.

     With oAgenda_Temp
        .Organiser = txtOrganiser.Text
        .Meeting = txtMeeting.Text
        .AgendaDate = New SmartDate(txtAgendaDate.Text)


        'Within the object Agenda_Temp class use the defined DAL which includes all the DC connect and stored procedures.  
        oAgenda_Temp.AgendaID = Agenda_TempDAL.AddAgenda_Temp(oAgenda_Temp)
    End With

End Sub
End Class

I understand that its telling me that the string value cannot be converted to a date but i don’t know hoe to resolve this as i am new to .net 2010?

Any help much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:17:57+00:00Added an answer on June 2, 2026 at 12:17 am

    Convert the string to a date before newing it:
    From MSDN:

    string date = "01/08/2008";
    DateTime dt = Convert.ToDateTime(date); 
    

    Your’s would become

    DateTime dt = Convert.ToDateTime(txtAgendaDate.Text)
    

    Then pass the date to your SmartDate constructor:

    oAgenda_Temp.AgendaDate = new SmartDate(dt)
    

    The final result:

      With oAgenda_Temp
            .Organiser = txtOrganiser.Text
            .Meeting = txtMeeting.Text
            .AgendaDate = New SmartDate(Convert.ToDateTime(txtAgendaDate.Text))
    
    
            'Within the object Agenda_Temp class use the defined DAL which includes all the DC connect and stored procedures.  
            oAgenda_Temp.AgendaID = Agenda_TempDAL.AddAgenda_Temp(oAgenda_Temp)
        End With
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web form that uses a lot of JavaScript and ajax to
![Snapshot of the problem][2] I have a web form that uses two update panels
I have a web form that uses if statements to create a string of
I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
I have some web application that uses jQuery to send AJAX requests to server.
I have a web application that uses ajax with prototype.js ( Ajax.Updater ). new
The Scenario I have an ASP.Net Web Project that uses a master page. This
I have a web form that uses AD to authenticate users. I want to
I have a web site that uses Membership and form authentication: ASP.NET Page: <asp:LoginView
I have a java web application that uses form based authentication. If a standard

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.