locked
Hidden Field produces unwanted results RRS feed

  • Question

  • User-723833757 posted

    I added a hidden field to my estimate request forms.

    I wanted the value to = to the current time so I added a page load event

    dateField.Value = DateTime.Now

    but when I submit the form, it now submits two of the same entry onto my database form (access)

    It didn't do this until I added the new hidden field. Can someone tell me if I did something wrong?

    Monday, December 1, 2008 7:01 PM

Answers

  • User-821857111 posted

    Like I said - use the built-in Access functions:

    InsertCommand="INSERT INTO [contactUs] ([firstName], [lastName], [Company], [Address], [City], [State], [zipCode], [Phone],[email] , [Comment], [dateField]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, Now() )

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 6, 2008 8:23 AM

All replies

  • User1096912014 posted

    If you can post some of your ASPX code and perhaps a bit of code behind, we may try to guess better. Otherwise there has to be a very powerful crystall ball to solve it.

    Tuesday, December 2, 2008 12:10 AM
  • User-821857111 posted

    Why are you storing the current time in a hidden field?  If you want to log what time the user submitted the form, just add Now() to your SQL string:

    Insert into mytable (mydatetimefield) Values (Now())

     

    Tuesday, December 2, 2008 2:51 AM
  • User-723833757 posted

        Protected Sub contactUs_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles contactUs.FinishButtonClick
            dateField.Value = DateTime.Now
            insertContactDataSource.Insert()
        End Sub



    <asp:AccessDataSource runat="server" DataFile="~/App_Data/Contact.mdb" InsertCommand="INSERT INTO [contactUs] ([firstName], [lastName], [Company], [Address], [City], [State], [zipCode], [Phone], [Email], [Comment], [dateField]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ID="insertContactDataSource">

     I am only using access because I am having trouble with SQL and my hosting company!

     I have tried this both ways - ie having it register as a page load event. - I just wanted to record the date and time the form was submitted

    Saturday, December 6, 2008 12:10 AM
  • User-821857111 posted

    Like I said - use the built-in Access functions:

    InsertCommand="INSERT INTO [contactUs] ([firstName], [lastName], [Company], [Address], [City], [State], [zipCode], [Phone],[email] , [Comment], [dateField]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, Now() )

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 6, 2008 8:23 AM
  • User-723833757 posted

    Thanks for that It worked for the date, but I still get duplicate entries into the database - for some reason it submits two of the same entry. Have any ideas? I even removed the hidden field and I still get 2 entries.

    Sunday, December 7, 2008 8:39 PM
  • User-821857111 posted

    Remove the AccessDataSource.Insert() command from your button click event.

     

    Monday, December 8, 2008 2:12 AM
  • User-723833757 posted

    I deleted it but I get this message

     

    "Property access must assign to the property or use its value."

     Am I understanding what is needed,

    I also tried something else, sending it as an email (without recording to db) and I get 2 email messages so something else must be wrong

     

     

    Wednesday, December 24, 2008 8:43 PM
  • User-723833757 posted

    Okay I figured it out, I made a user control instead of using the wizard control, It fixed the problem so it had something to do with the wizard control having two steps

    Wednesday, December 24, 2008 11:59 PM