BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
Hi,
I have a form with various controls, which captures input from user. How do I capture and store all values to DB? I am using EF / Model. Here is a sample code snippet.
<form>
<div class="row material2">
<div class="col-xs-2 col-sm-2 col-lg-2 col-md-2 e-rtl">
<b>Name</b>
</div>
<div class="col-xs-4 col-sm-4 col-lg-4 col-md-4">
<ejs-textbox id="txtBuyerName" cssClass="e-outline required" floatLabelType="Auto"></ejs-textbox>
</div>
</div>
<div class="row material2">
<div class="col-xs-2 col-sm-2 col-lg-2 col-md-2 e-rtl">
<b>: Address 1</b>
</div>
<div class="col-xs-4 col-sm-4 col-lg-4 col-md-4">
<ejs-textbox id="txtAddress1" cssClass="e-outline" floatLabelType="Auto"></ejs-textbox>
</div>
<div class="row material2">
<div class="col-xs-2 col-sm-2 col-lg-2 col-md-2"></div>
<div class="col-xs-2 col-sm-2 col-lg-2 col-md-2 ">
<ejs-button id="btnSave" onclick="SaveData" content="Save Data" isPrimary="true"></ejs-button>
</div>
</div>
</form>
<form method="post">
<ejs-textbox id="textboxfor" name="firstname" placeholder="First Name" floatLabelType="Auto" ejs-for="@Model.firstname"></ejs-textbox>
<div id="errorMessage">
<span asp-validation-for="firstname"></span>
</div>
<div id="submitbutton">
<ejs-button id="submitButton" content="Post"></ejs-button>
</div>
</form>
|
public class TextBoxValue
{
[Required(ErrorMessage = "Value is required")]
public string firstname { get; set; }
}
TextBoxValue textbox = new TextBoxValue();
public IActionResult Index()
{
textbox.firstname = "John";
return View(textbox);
}
[HttpPost]
public IActionResult Index(TextBoxValue model)
{
textbox.firstname = model.firstname;
return View(textbox);
}
|
Thank you Aravinthan! That works with a Controller, i am injecting a service and still having some issues binding the variables for that communication. I will let you know how it goes!
Thanks,
Sunil
Hello, I was able to get through it successfully! One other question.
I have 2 controls - one Dropdown and one textbox. i want to show/hide one of those based on a checkbox selection. HOw can i do that?
Thank you for your help in advance!
-Sunil
<ejs-checkbox id="ddb" label="Hide DropDownButton" change="ddbChange"></ejs-checkbox>
<ejs-checkbox id="textbox" label="Hide TextBox" change="textChange"></ejs-checkbox>
<div class="control-section">
<div class="control_wrapper accordion-control-section">
<ejs-textbox id="firstname" placeholder="First Name" width="100px"></ejs-textbox>
</div>
<br />
<div class="control_wrapper accordion-control-section">
<ejs-dropdownbutton id="element" content="Edit" items="ViewBag.items"></ejs-dropdownbutton>
</div>
</div>
<script>
function ddbChange(args) {
var dropdownObj = document.getElementById("element").ej2_instances[0];
if (args.checked) {
dropdownObj.cssClass = "e-hide";
} else {
dropdownObj.cssClass = "";
}
}
function textChange(args) {
var textEle = document.getElementById("firstname");
if (args.checked) {
textEle.parentElement.style.display = 'none';
} else {
textEle.parentElement.style.display = 'block';
}
}
</script>
<style>
.e-hide{
display:none;
}
</style>
|
Thank you Aravinth! It worked like a charm!
I tried to use this pattern for another requirement, but seems to run into another issue. I have one dropdown (country), and based on a certain value selected (say USA), I need to hide/show another two controls.
Here is the code snippet I have.
<div >
<ejs-dropdownlist id="ddlCountry" cssClass="e-outline e-small" floatLabelType="Auto"
change="countryChange" datasource="@Model.countries" ejs-for="buyer.Country" allowFiltering="true" filterType="Contains" filterBarPlaceholder="Search Country...">
<e-dropdownlist-fields text="DisplayText" value="Value"></e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
<div>
<b>: State</b>
</div>
<div class="col-xs-4 col-sm-4 col-lg-4 col-md-4">
<ejs-textbox id="txtState" cssClass="e-outline e-small" floatLabelType="Auto"></ejs-textbox>
<ejs-dropdownlist id="ddlState" cssClass="e-outline e-small" floatLabelType="Auto" dataSource="@Model.usaStates" ejs-for="buyer.State" >
<e-dropdownlist-fields text="DisplayText" value="Id"></e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
I need to hide the textbox or state dropdown when a certain value is selected.
function countryChange(args) {
// disable the state DropDownList & show state Text box when country is USA
var txtState = document.getElementById('txtState');
var ddlState = document.getElementById('ddlState').ej2_instances[0];
var ddlCountry = document.getElementById('ddlCountry').ej2_instances[0];
var country = ddlCountry.value;
if(country == "USA")
{
ddlState.cssClass = "e-hide";
txtState.cssClass = "";
}
<style>
.e-hide{
display:none;
}
</style>
<div class="hide">
<ejs-textbox id="txtState" cssClass="e-outline e-small" floatLabelType="Auto"></ejs-textbox>
</div>
<div class="hide">
<ejs-dropdownlist id="ddlState" cssClass="e-outline e-small" floatLabelType="Auto" dataSource="@Model.usaStates" ejs-for="buyer.State" >
<e-dropdownlist-fields text="DisplayText" value="Id"></e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
<script>
function countryChange(args) {
. . . . . . . . . .
if(country == "USA")
{
ddlState.element.closest(".hide").style.display = "none";
txtState.element.closest(".hide").style.display = "";
}
else {
ddlState.element.closest(".hide").style.display = "";
txtState.element.closest(".hide").style.display = "none";
}
}
</script>
|
thank you for your help, Prince!
Hi,
How can l accomplish saving form data input into database with angular?
Hi Charles,
We suggest you refer the below public blogs for the requested requirement,
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Udhaya Kumar D
Hi Udhaya,
I already know how to save angular form inputs data into sql server database using angular service. I was only trying to explore more possible options.
Regards
Charles
Hi Charles,
We are curious to know, what complexity are you facing on your end. So, please share the below details to validate the requirement further and provide you with a prompt solution.
Udhaya Kumar D