I feel like a fish out of water here...freshly dipping my toes into the ASP.net world, but finding it quite fascinating so far.
Let me begin at the starting line:
Background: I am currently working on an ASP.net MVC5 application that involves user login information. Users will be able to create accounts, receive messages, and more. The key feature is a form on the site where users can submit information using a Conditional Logic HTML Form with radio buttons, text areas, and other elements. My ultimate objective is to allow users to fill out and submit the form, save it to the MySQL database, send an email to both the admin and the user with the selected details, and display their responses in their "Account Dashboard" section.
Problem: I'm facing a challenge in extracting user-submitted information based on their radio button selection in the HTML Form, which can fall under three different scenarios:
- Web Project
- 2D Design Project
- 3D Design Project
For instance, if a user selects "Web" instead of "Graphic" in the "Project Type" field, they should only be submitting values related to "Web". However, I'm uncertain about the best approach to tackle this issue...
Here's a snippet of the code I've started working on for when a user chooses a Web project for submission to the database:
if (IsPost) && (RadioButton.projectType.Equals(Web))
{
projectType = Request.Form["Web"];
TypeOfWebsite = Request.Form["TypeOfWebsite"];
DeviceExperience = Request.Form["DeviceExperience"];
}
Below are the form values:
<form method="post">
<br />
<!--Form fields go here-->
</form>
I have referred to various MSDN tutorials to gain a better understanding:
- http://www.asp.net/web-pages/tutorials/introducing-aspnet-web-pages-2/form-basics
- http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobutton.aspx
However, these resources haven't provided clear guidance on how to implement the three conditional statements necessary for my form:
- "If user selects Project Type = "Web" and submits the form, save the data to the database"
- "If user selects Project Type = "Graphic" and Dimension = "2D" upon form submission, store the relevant values"
- "If user selects Project Type = "Graphic" and Dimension = "3D" when submitting the form, save the corresponding values to the database"
Recap:
- How do I write the conditional statement to achieve this?
- Should I reconsider the HTML form structure I'm currently using in favor of ASP Web Pages?
I have also implemented some JavaScript to dynamically display available form values based on user selections. It's functioning as expected! I now need assistance in linking this information to the database for user profile usage. Any insights or solutions would be greatly appreciated!