Академический Документы
Профессиональный Документы
Культура Документы
CONTA CT
A B OUT
Search here....
ROAD MAP
CATEGORIES
BEST PRACTICES
DESIGN PATTERNS
Home ASP.NET MVC C# CSS jQuery Handling Multiple Entries and One Time Post in ASP.NET MVC
ABOUT ME
Winifred Cadap
Introduction
Follow
CATEGORIES
AngularJS (6)
ASP.NET (1)
One type of Data Entry patterns in Web Application is multiple data entry. Examples
of these multiple data entry are orders entry, guests registration, etc. In this
BootStrap (4)
be working.
C# (18)
CSS (6)
Design Patterns (10)
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!
Download:
UX (2)
Visual Studio (1)
POPULAR POSTS
ASP.NET MVC 4
jQuery
CSS
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!
HTML 5
How do we do this?
One approach is to loop through the web form and capture the values in the form.
We can do this in the controller. That's it!
The Code:
1
2
3
4
5
6
7
8
9
namespace MultipleEntry.Models
{
public class Client
{
public int Id { get; set; }
public string ClientName { get; set; }
public string Email { get; set; }
}
}
The View:
We are going to use plain HMTL and jQuery to do the data capturing. We use jQuery
to manipulate the DOM.
1
2
3
Implementing Breadcrumb In
AngularJS Using Angular-UIRouter
O ne of the thing that is missing in
AngularJS API is the...
@model MultipleEntry.Models.Client
@{
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
ViewBag.Title = "Index";
}
<h2>Client Registration</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Client Registration</legend>
<table id="clientTable" class="table table-bordered">
<thead>
<tr>
<td>Client Name</td>
<td>Email</td>
<td></td>
</tr>
</thead>
BLOG ARCHIVE
2015 (7)
2014 (23)
October (3)
September (1)
August (1)
July (13)
Adapter Design Pattern
Unit of Work Design Pattern
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
June (4)
May (1)
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
var counter = 1;
$(function () {
$('#addButton').click(function () {
$('<tr id="tablerow' + counter + '"><td>' +
'<input class="text-box single-line" name="ClientName[' + counter + ']" type="text" value="" required="required" />' +
'</td>' +
'<td>' +
'<input type="email" class="text-box single-line" name="Email[' + counter + ']" value="" required="required" />' +
'</td>' +
'<td>' +
'<button type="button" class="btn btn-primary" onclick="removeTr(' + counter + ');">Delete</button>' +
'</td>' +
'</tr>').appendTo('#clientTable');
counter++;
return false;
});
});
function removeTr(index) {
if (counter > 1) {
$('#tablerow' + index).remove();
counter--;
}
return false;
}
</script>
}
view raw
The Controller:
In the controller, we loop through the form and capture the data. Save it to a list
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[HttpPost]
public ActionResult Index(string any = "")
{
IList<Client> _Client = new List<Client>();
//Loop through the forms
for (int i = 0; i <= Request.Form.Count; i++)
{
var ClientName = Request.Form["ClientName[" + i + "]"];
var EMail = Request.Form["Email[" + i + "]"];
if ((ClientName != null) && (EMail != null))
{
_Client.Add(new Client { ClientName = ClientName, Email = EMail });
}
}
//Once you got the records then you can do anything
return View();
}
view raw
How to Verify:
One way to verify that the data has been captured is by placing a breakpoint and
run the application in a debug mode.
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!
Like
Share
RELATED POSTS :
Handling Multiple
Entries and One T...
Preventing BootStrap
Alert From Bei...
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!
Post a Comment
Newer Post
Home
Older Post
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!
Let your visitors save your web pages as PDF and set many options for the layout! Use a download as PDF link to PDFmyURL!