function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gerald GeorgeGerald George 

post fields from web to lead form with mvc c# both to salesfoce and sql

I want to post form fields from my web page into salesforce via web to lead and also in my local database.  Can anyone show me how to do this with .Net mvc c# ? I have common fields like user name,email,phone etc 
Please look at my code here



my code
<script type="text/javascript">
        function submitPractice() {
            webToLead({
                oid: '00D20000000l2qZ'
                //,debug:1
                //, debugEmail: 'gerald@ghanafx.com'
 , first_name: $("#PracticeUserDetail_FirstName").val()
 , last_name: $("#PracticeUserDetail_LastName").val()
 , email: $("#Email").val()
 , country_code: $("#PracticeUserDetail_Country").val()
 , lead_source: 'web demo'
 , description: 'This is an automated transparent lead'
            });

            //practiceform
            var formData = JSON.stringify($("#practiceform").serializeArray());
            $.ajax({
                type: "POST",
                url: "/Account/Practice",
                data: formData,
                success: function () { },
                dataType: "json",
                contentType: "application/json"
            });

        }
function webToLead(fields) {
 var customHiddenIframeName='JLA_API';
 if(!document.getElementById(customHiddenIframeName)){
  var theiFrame=document.createElement("iframe");
  theiFrame.id=customHiddenIframeName;
  theiFrame.name=customHiddenIframeName;
  theiFrame.src='about:blank';
  theiFrame.style.display='none';
  document.body.appendChild(theiFrame);
 }
 fields['retURL'] = 'http://166.62.127.6/';//dummy URL
 var form = document.createElement("form");
 form.method = "POST";
 form.action = "https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8";
 form.setAttribute("target", customHiddenIframeName);
 for (var fieldName in fields) {
  var theInput = document.createElement("input");
  theInput.name=fieldName;
  theInput.value=fields[fieldName];
  theInput.setAttribute("type", "hidden");
  form.appendChild(theInput);
 }
 document.body.appendChild(form);
 form.submit();
}
    </script>