Radio button and date's problem my ASP.NET

Harun Ergün 260 Reputation points
2023-05-11T14:22:07.8233333+00:00

Friends, first of all hello.

I'm designing a simple form site. But I'm getting an error. Texts are writing to the database, but the radio button and date does not write the error explodes. I left the whole code for you to review. I need helpUser's image

User's image

User's image

User's image

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
SQL Server Other
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-05-11T15:18:27.3766667+00:00

    The form[fieldname] method returns a string, which does not have a .Value() method. You use Int32.Parse() and DateTime.Parse().


  2. AgaveJoe 30,126 Reputation points
    2023-05-11T15:22:40.4533333+00:00

    I recommend that you learn MVC model binding which handles type validation and converting the post parameters into a type.

    If we go with your current approach, then you need to validate, which is not included, and convert the inputs yourself.

    DateTime dt = DateTime.ParseExact(Request.Form["LisansBasLangicTarihi"], "dd/MM/yyyy", CultureInfo.InvariantCulture);
    int num = int.Parse(Request.Form["Gender"]);
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.