Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 469.5k

Submitting a form to be inserted to database sql?

Mar 19 2020 2:32 AM
Hi Team
 
I have this form that have created, i have created a table name on the database, i want to find out from this logic how do i submit it to that table name? Do i need to create store procedure as well? Mine does not do any crud operation, just it need to send this raw data to the table.
 
  1. @using eNtsaRegistrationTraining.Models  
  2. @model  EditTrainingRegFormViewModel  
  3.   
  4. @{  
  5.     ViewBag.Ttile = "Dashboard";  
  6.     Layout = "~/Views/Shared/_HomeLayout.cshtml";  
  7. }  
  8.   
  9. <!---This form is for registration within a Dashbaord layout-->  
  10. <center>  
  11.     <div class="z-inex" style="width:1000px;">  
  12.         <div class="register-logo">  
  13.   
  14.         </div>  
  15.   
  16.         <div class="card">  
  17.             <div class="card-body register-card-body">  
  18.                 <center>  
  19.                     <img src="~/Images/eNtsa.png" />  
  20.                 </center>  
  21.                 <center>  
  22.                     <h1>  
  23.                         <p><b>Training Course Registration:Motion MasterClass</b></p>  
  24.                     </h1>  
  25.                     <hr />  
  26.                     <p>Course date: 25-27 February 2020</p>  
  27.                     <hr />  
  28.                     <p>  
  29.                         Note:Please note your registration is submit approval as seats for this course is limited. Once your registration is confirmed, you will receive a quote for subject to your confirmation  
  30.                         followed by an invoice.  
  31.                     </p>  
  32.                 </center>  
  33.                 <hr />  
  34.                 @using (Html.BeginForm("editRegForm""Home", FormMethod.Post, new { @role = "form" }))  
  35.                 {  
  36.                     @Html.AntiForgeryToken()  
  37.                     <div class="row">  
  38.                         <label for="Title">Title:</label>  
  39.                         <div class="input-group col-md-3 col-md-offset-3 col-sm-3 col-xs-3 ">  
  40.                             <div class="input-group pull-right">  
  41.                                                   
  42.                                 @Html.TextBoxFor(m => m.Title, new { @class = "form-control", type = "text", id = "title", autofocus = "autofocus", placeholder = "Title", required = "required" })  
  43.                                 <div class="input-group-append">  
  44.                                     <div class="input-group-text">  
  45.   
  46.                                     </div>  
  47.                                 </div>  
  48.                             </div>  
  49.   
  50.                         </div>  
  51.                     </div>  
  52.                     <hr />  
  53.                     <form>  
  54.                         <div class="input-group mb-2">  
  55.                             <div class="input-group-prepend">  
  56.   
  57.                             </div>  
  58.                             <label for="firstName">Name:</label>  
  59.                             <div class="input-group col-md-7 col-md-offset-7 col-sm-7 col-xs-7">  
  60.                                 <div class="input-group pull-right">  
  61.                                                   
  62.                                     @Html.TextBoxFor(m => m.FirstName, new { @class = "form-control", type = "text", id = "firstname", autofocus = "autofocus", placeholder = "First Name", required = "required" })                 
  63.   
  64.                                     @Html.TextBoxFor(m => m.LastName, new { @class = "form-control", type = "text", id = "lastname", autofocus = "autofocus", placeholder = "Last Name", required = "required" })  
  65.                                     <div class="input-group-append">  
  66.                                         <div class="input-group-text">  
  67.                                         </div>  
  68.                                     </div>  
  69.                                 </div>  
  70.                             </div>  
  71.                         </div>  
  72.                     </form>  
  73.   
  74.                     <hr />  
  75.   
  76.                     <div class="row">  
  77.                         <label for="Position">Position</label>  
  78.                         <div class="input-group col-md-3 col-md-offset-3 col-sm-3 col-xs-3">  
  79.                             <div class="input-group pull-right">  
  80.                                              
  81.                                 @Html.TextBoxFor(m => m.Position, new { @class = "form-control", type = "text", id = "position", autofocus = "autofocus", placeholder = "Position", required = "required" })  
  82.                                 <div class="input-group-append">  
  83.                                     <div class="input-group-text">  
  84.   
  85.                                     </div>  
  86.                                 </div>  
  87.                             </div>  
  88.                         </div>  
  89.   
  90.                     </div>  
  91.                     <hr />  
  92.                     <div class="row">  
  93.                         <label for="Address">Company</label>  
  94.                         <div class="input-group col-md-3 col-md-offset-3 col-sm-3 col-xs-3">  
  95.                             <div class="input-group pull-right">  
  96.                                            
  97.                                 @Html.TextBoxFor(m => m.Company, new { @class = "form-control", type = "text", id = "company", autofocus = "autofocus", placeholder = "Company", required = "required" })  
  98.                                 <div class="input-group-append">  
  99.                                     <div class="input-group-text">  
  100.   
  101.                                     </div>  
  102.                                 </div>  
  103.                             </div>  
  104.                         </div>  
  105.                     </div>  
  106.   
  107.                     <hr />  
  108.                     <div class="row">  
  109.                         <label for="Address">Address</label>  
  110.                         <div class="input-group col-md-6.9 col-md-offset-6 col-sm-6 col-xs-6">  
  111.                             <div class="input-group pull-left">  
  112.                                               
  113.                                 @Html.TextBoxFor(m => m.Address, new { @class = "form-control", type = "text", id = " street address", autofocus = "autofocus", placeholder = "Street Address", required = "required" })  
  114.                                 <div class="input-group-append">  
  115.                                     <div class="input-group-text">  
  116.   
  117.                                     </div>  
  118.                                 </div>  
  119.   
  120.                             </div>  
  121.   
  122.                         </div>  
  123.                     </div>  
  124.                     <hr />  
  125.                     <div class="row">  
  126.                         <div class="input-group col-md-8.0 col-md-offset-6 col-sm-6 col-xs-6">  
  127.                             <div class="input-group pull-right">  
  128.                                                                 
  129.                                 @Html.TextBoxFor(m => m.Address, new { @class = "form-control", type = "text", id = " street address line 2", autofocus = "autofocus", placeholder = "Street Address Line 2", required = "required" })  
  130.                                 <div class="input-group-append">  
  131.                                     <div class="input-group-text">  
  132.   
  133.                                     </div>  
  134.                                 </div>  
  135.                             </div>  
  136.                         </div>  
  137.                     </div>  
  138.                     <hr />  
  139.                     <form>  
  140.                         <div class="input-group mb-2">  
  141.                             <div class="input-group-prepend">  
  142.   
  143.                             </div>  
  144.   
  145.                             <div class="input-group col-md-7 col-md-offset-7 col-sm-7 col-xs-7">  
  146.                                 <div class="input-group pull-right">  
  147.                                                                   
  148.                                     @Html.TextBoxFor(m => m.City, new { @class = "form-control", type = "text", id = "city", autofocus = "autofocus", placeholder = "City", required = "required" })                 
  149.   
  150.                                     @Html.TextBoxFor(m => m.State, new { @class = "form-control", type = "text", id = "state", autofocus = "autofocus", placeholder = "State/ Province", required = "required" })  
  151.   
  152.                                     <div class="input-group-append">  
  153.                                         <div class="input-group-text">  
  154.                                         </div>  
  155.                                     </div>  
  156.                                 </div>  
  157.                             </div>  
  158.                         </div>  
  159.                         <hr />  
  160.                         <!--Zip code for postal code-->  
  161.                         <div class="input-group mb-2">  
  162.                             <div class="input-group-append">  
  163.   
  164.                             </div>  
  165.                             <div class="input-group col-md-3 col-md-offset-3 col-sm-2 col-xs-2">  
  166.                                 <div class="input-group pull-right">  
  167.                                                                   
  168.                                     @Html.TextBoxFor(m => m.Code, new  
  169.                                {  
  170.                                    @class = "form-control",  
  171.                                    type = "text",  
  172.                                    id = "postal code",  
  173.                                    autofocus = "autofocus",  
  174.                                    placeholder = "Postal/Zip Code"  
  175.                                      
  176.                                })  
  177.                                    @Html.ValidationMessageFor(m => m.Code, ""new { @class = "text-danger" })  
  178.                                     <div class="input-group-append">  
  179.                                         <div class="input-group-text">  
  180.   
  181.                                         </div>  
  182.                                     </div>  
  183.   
  184.                                 </div>  
  185.                             </div>  
  186.                         </div>  
  187.                     </form>  
  188.                     <div class="row">  
  189.                         <label for"Email">Email:</label>  
  190.                         <div class="input-group col-md-4 col-md-offset-2 col-sm-2 col-xs-2">  
  191.                             <div class="input-group pull-right">  
  192.                                                   
  193.                                 @Html.TextBoxFor(m => m.Email, new { @class = "form-control", type = "email", id = "inputEmail" , placeholder = "[email protected]",   
  194.                                 required = "required",  
  195.                                  pattern = @"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$", title = "This field is required"})  
  196.                                 @Html.ValidationMessageFor(m => m.Email, " "new { @class = "text-danger" })  
  197.                                 <div class="input-group-append">  
  198.                                     <div class="input-group-text">  
  199.   
  200.                                     </div>  
  201.                                 </div>  
  202.                             </div>  
  203.                         </div>  
  204.                     </div>  
  205.   
  206.                     <hr />  
  207.                     <div class="row">  
  208.                         <label for="Attendee Cell Number">Cell Number:</label>  
  209.                         <div class="input-group col-md-3 col-md-offset-1 col-sm-1 col-xs-1">  
  210.                             <div class="input-group pull-right">  
  211.                                      
  212.                                 @Html.TextBoxFor(m => m.Cell_Number, new { @class = "form-control", type = "text", autofocus = "autofocus", required = "required" })  
  213.                                 @Html.ValidationMessageFor(m => m.Cell_Number, " "new { @class = "text-danger" })  
  214.                                 <div class="input-group-append">  
  215.                                     <div class="input-group-text">  
  216.   
  217.                                     </div>  
  218.                                 </div>  
  219.                             </div>  
  220.                         </div>  
  221.                     </div>  
  222.   
  223.                     <hr/>  
  224.                     <form>  
  225.                         <div class="row">  
  226.                             <label for="Please verify that you are a human">Please verify that you are a human</label>                    
  227.   
  228.                             <div class="input-group col-md-3 col-md-offset-1 col-xs-1">  
  229.                                 <div class="input-group pull-left">  
  230.                                     @using (Html.BeginForm("FormSubmit""Home", FormMethod.Post))  
  231.                                     {  
  232.                                         <div class="g-recaptcha" data-sitekey="6LezHOIUAAAAANq0FvFWWbvBlb6Vc1Y2YwnixVqJ">  
  233.   
  234.                                         </div>  
  235.   
  236.                                     }  
  237.                                 </div>  
  238.                             </div>  
  239.   
  240.                         </div>  
  241.                         <hr />  
  242.   
  243.                         <div class="row">  
  244.                             <label for="Dietary Requirements">Dietary Requirements</label>  
  245.                             <div class="input-group col-md-offset-3 col-sm-6 col-xs-6">  
  246.                                 <div class="input-group pull-left">  
  247.                                   
  248.                                 </div>  
  249.                             </div>  
  250.   
  251.                         </div>  
  252.                     </form>  
  253.   
  254.                     <hr/>  
  255.   
  256.                     <!--Submit form button to allow insert data to db-->  
  257.                     <div class="form-group">  
  258.                         <hr/>  
  259.                         <button type="button" class="btn btn-primary">Submit</button>  
  260.                     </div>  
  261.                     
  262.                 }  
  263.             </div>  
  264.             </div>  
  265.         </div>  
  266. </center>  
  267.              
  268. <!----Javascript for form validation including recapture on Google-->  
  269.   
  270. <script src="https://www.google.com/recaptcha/api.js" type="text/javascript">  
  271. </script>  
 

Answers (1)