I use asp.net-mvc, entity framework. My view is like below:
<td class="center">
<span id="spanitem_#item.UrunId">#item.Fiyat</span>
<input type="text" id="textfiyat_#item.UrunId" value="" class="displaynone textwidth90"/>
</td>
<td class="center">
<span id="spanitem_#item.UrunId">#item.Adet</span>
<input type="text" id="textadet_#item.UrunId" value="" class="displaynone textwidth90"/>
</td>
<td class="center">
<span id="spanitem_#item.UrunId">
#item.Fiyat)*#item.Adet
</span>
</td>
Fiyat field is decimal, Adet field is int. I want to show their multiplying. But i can not.
How can I achieve this. Thanks...
Have you tried #(item.Fiyat * item.Adet)
You can try it-
#(item.Fiyat * item.Adet)
Related
This is the third question on this topic. Hopefully I’ve improved the question as I struggle with wrapping up this project. First, let’s look at the page with the Dropdown list of Alert_Identifiers—the key value that gets data from the mysql database for the project. AlertPick.cshtml:
#model IEnumerable<edxl_cap_v1_2.Models.ContentViewModels.Alert>
#using edxl_cap_v1_2.Models.ContentViewModels
#{
ViewData["Title"] = "PickAlert";
}
<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="~/css/capv1_2_refimp.css" />
<title>#ViewBag.Title</title>
</head>
<h4>Alert</h4>
<div>
#ViewBag.Message
</div>
<style>
tr:nth-child(even) {
background-color: lightBlue;
}
tr:nth-child(odd) {
background-color: white;
}
</style>
<table class="smallText">
#foreach (var item in Model)
{
<tr>
<td>
</td>
<td>
<div id="elementInput">
<span class="smallText">
#Html.DisplayNameFor(model => model.Alert_Identifier) value
<input type="text" name="elementValue" value="#Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
</span>
</div>
</td>
<td>
<text> </text>
</td>
<td>
<form asp-area="" asp-controller="alerts" asp-action="_DetailsAlert" method="post" asp-route-id="#item.AlertIndex">
<input type="hidden"
name="Identifier"
value="#Html.DisplayFor(modelItem => item.Alert_Identifier)">
<input type="submit"
value="Check Alert">
</form>
</td>
<td>
<text> </text>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div id="elementInput">
<span class="smallText">
#Html.DisplayNameFor(model => model.Alert_Identifier) value
<input type="text" name="elementValue" value="#Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
</span>
</div>
</td>
<td>
<text> </text>
</td>
<td>
<form asp-area="" asp-controller="infos" asp-action="_DetailsInfo" method="post" asp-route-id="#item.AlertIndex">
<input type="hidden"
name="Identifier"
value="#Html.DisplayFor(modelItem => item.Alert_Identifier)">
<input type="submit"
value="Check Info">
</form>
</td>
<td>
<text> </text>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div id="elementInput">
<span class="smallText">
#Html.DisplayNameFor(model => model.Alert_Identifier) value
<input type="text" name="elementValue" value="#Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
</span>
</div>
</td>
<td>
<text> </text>
</td>
<td>
<form asp-area="" asp-controller="areas" asp-action="_DetailsArea" method="post" asp-route-id="#item.AlertIndex">
<input type="hidden"
name="Identifier"
value="#Html.DisplayFor(modelItem => item.Alert_Identifier)">
<input type="submit"
value="Check Area">
</form>
</td>
<td>
<text> </text>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div id="elementInput">
<span class="smallText">
#Html.DisplayNameFor(model => model.Alert_Identifier) value
<input type="text" name="elementValue" value="#Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
</span>
</div>
</td>
<td>
<text> </text>
</td>
<td>
<form asp-area="" asp-controller="resources" asp-action="_DetailsResource" method="post" asp-route-id="#item.AlertIndex">
<input type="hidden"
name="Identifier"
value="#Html.DisplayFor(modelItem => item.Alert_Identifier)">
<input type="submit"
value="Check Resource">
</form>
</td>
<td>
<text> </text>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div id="elementInput">
<span class="smallText">
#Html.DisplayNameFor(model => model.Alert_Identifier) value
<input type="text" name="elementValue" value="#Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
</span>
</div>
</td>
<td>
<text> </text>
</td>
<td>
<form asp-area="" asp-controller="EdxlCapMessageViewModels" asp-action="_Assemble" method="post" asp-route-id="#item.AlertIndex">
<input type="hidden"
name="Identifier"
value="#Html.DisplayFor(modelItem => item.Alert_Identifier)">
<input type="submit"
value="Add All">
</form>
</td>
<td>
<text> </text>
</td>
</tr>
}
</table>
Once the Alert_Identifier that corresponds to one record in the database is selected and the submit button is clicked, the browser opens this page
The first four rows work correctly when the “Check XXX” submit button is clicked. They show the individual data category “_DetailsXXX.cshtml” page one at a time. Here is the screen of the page showing the _DetailsAlert.cshtml page.
This is set up so that these pages can be reviewed individually and the composite page, once working, will also work in the “Review” page and the “Approve” page. In the case of the “Assemble” page here, the four individual pages are intended to appear composited together when the “Add All” submit button is clicked, but currently these pages appear without data values for the data items.
I am also going to ping a couple of more experienced people who have helped me previously to take a look at this, I am also studying a wholly different injection mechanism for injecting data into the program where needed which I will consider using in the follow-on specfications.
Lastly, I am rexbroo at GitHub.com where you can find nearly identical Visual Studio programs in the repos: edxl_cap_v1_2-VS4Win (for Windows) and edxl_cap_v1_2-VS4Mac (for Mac) and edxl_cap_v1_2,sql-mysql-VisualStudio where the most current dump of the database is 20180928.
<input type="text" name="elementValue" value="#Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
You don't need to use the #Html.DisplayFor helper here. Just use:
<input type="text" name="elementValue" value="#item.Alert_Identifier" size="60" />
None of your input values should be using the Html.DisplayFor. That is inserting a tag into the value when all you really want is the value of the property.
Also, I question the reason for using multiple forms on a page. Could you use a single form and post to a single action? Do you need to post at all? Could the action be refactored into a get and let you use a <a> tag instead?
I have made grid with html table tag .in one of TD tag I have this code
<td>
<a onclick="$('#lightBox').css('display','inline')"></a>
<div style="display: none" id="lightbox">
<%--<%Html.RenderAction("LightBox","PremiumSharingAdmin",new {historyId = premium.SharingPremiumHistoryID}); %>--%>
<img src="Storage/Images/<%=premium.SharingPremiumHistoryID %>.jpg" title="image" width="100" height="100"/>
<div>
<textarea readonly="readonly">
<%= premium.Content %>
</textarea>
</div>
<div>
<input type="text" readonly="readonly" value="<%= premium.SharingTitle %>"/>
</div>
</div>
</td>
These tag provide me some extra info from grid row that By default is hidden.
In other side I have Link tag that if user pressed that display that row.
but problem is that when I pressed it, it just show me the first record detail and when I press the others it show me the first row detail.
where is the problem guys ?
This is my whole ASPX view
<% foreach (var premium in Model)
{%>
<tr>
<td style=" font-weight: bold;width: 130px;">
<span ><%= premium.SharingTitle %></span>
</td>
<td style=" font-weight: bold;width: 130px;">
<span ><%= premium.AddedDate.ConvertToPersianDate(true) %></span>
</td>
<td style="width: 130px;">
<span> <%= premium.IsSubmit %></span>
</td>
<td style="width: 130px;">
<span> <%= premium.ResturantName %></span>
</td>
<td style="width: 130px;">
<span> <%= premium.Content %></span>
</td>
<td style="width: 130px;">
<div class="group">
<a class="delete" href="<%= Url.Action("submit", "PremiumSharingAdmin", new {historyId = premium.SharingPremiumHistoryID}) %>" onclick="return confirm('آیا میخواهید این خبر را تایید کنید؟');">تایید</a>
</div>
</td>
<td>
<a onclick="$('#lightBox').css('display','inline')"></a>
<div style="display: none" id="lightBox">
<%--<%Html.RenderAction("LightBox","PremiumSharingAdmin",new {historyId = premium.SharingPremiumHistoryID}); %>--%>
<img src="Storage/Images/<%=premium.SharingPremiumHistoryID %>.jpg" title="image" width="100" height="100"/>
<div>
<textarea readonly="readonly">
<%= premium.Content %>
</textarea>
</div>
<div>
<input type="text" readonly="readonly" value="<%= premium.SharingTitle %>"/>
</div>
</div>
</td>
</tr>
<%} %>
You are generating invalid html by giving multiple <div> elements the same id attribute. $('#lightBox').css('display','inline') will return all elements with id="lightbox" but set the style of only the first.
Instead, use class names and use relative selectors. I also recommend you use Unobtrusive Javascript and css, rather tan polluting your mark up with behavior.
Html
<td>
Show
<div class="lightbox">Some content to display</div>
</td>
CSS
.lightbox {
display: none;
}
Script (at bottom of page)
<script>
$('.toggle').click(function () {
if ($(this).hasClass('hidden')) {
$(this).next('div').show();
$(this).text('Hide');
} else {
$(this).text('Show');
$(this).next('div').hide();
}
$(this).toggleClass('hidden');
});
</script>
</body>
Side note: Using RenderAction to render the contents of the hidden div suggest the contents are large and/or you calling a service/database to get the contents. If that's the case you should be loading the contents on demand using ajax (unless your expecting the users to view the details of all rows)
I have inputtext filed in my gsp llike this :
<tr class="context">
<td width="5%" ><a class="addButton" href="#" style="display:none;" >+</a></td>
<td width="60%"><input type="text" name="iwd0_description" value="" id="iwd0_description" /></td>
<td width="10%"><input type="text" name="iwd0_tax" value="" id="iwd0_tax" /></td>
<td width="10%"><input type="text" name="iwd0_discount" value="" id="iwd0_discount" /></td>
<td width="10%"><input type="null" name="iwd0_total" value="0" required="" id="iwd0_total" /></td>
<td width="5%" ><a class="deleteButton" href="#" style="display:none;" >-</a></td>
</tr>
<tr class="context">
<td width="5%" ><a class="addButton" href="#" style="display:none;" >+</a></td>
<td width="60%"><input type="text" name="iwd1_description" value="" id="iwd1_description" /></td>
<td width="10%"><input type="text" name="iwd1_tax" value="" id="iwd1_tax" /></td>
<td width="10%"><input type="text" name="iwd1_discount" value="" id="iwd1_discount" /></td>
<td width="10%"><input type="null" name="iwd1_total" value="0" required="" id="iwd1_total" /></td>
<td width="5%" ><a class="deleteButton" href="#" style="display:none;" >-</a></td>
</tr>
How can I access to input value in my controller?
Form values are sent over HTTP using request parameters (for GET requests), with the input name attribute used to set the parameter "key". So your HTTP request will have the following params: ?iwd0_tax=userInput1&iwd0_discount=userInput2 etc.
Grails makes request parameters available by the params var in controllers:
def iwd0_tax = params.iwd0_tax
Grails can also populate a bean/class from the request params automatically. The bean is called a command object. See details in the Grails docs.
def i = 0
while (params."iwd${i}_tax") {
println 'tax'+"${i}" + params."iwd${i}_tax"
i++
}
I need help creating an 'edit' action that selects a specific model from a list of models, and in that table, edits the model. A quick-edit of sorts.
<tbody>
{{#each}}
<tr class="people-list">
<td>
<input type="checkbox" class="toggle">
<label class="category-text">{{#linkTo 'category' this}}{{Name}}{{/linkTo}} </label>
<img class="table-img" src="images/x.png">
<img class="table-img" {{action 'edit'}} src="images/pencil-grey.png">
</td>
</tr>
{{/each}}
</tbody>
By clicking {{action 'edit'}}, {{Name}} becomes and editable input. This is all done without leaving the '/categories' url.
Thanks guys :D
<tbody>
{{#each}}
<tr class="people-list">
<td>
<input type="checkbox" class="toggle">
{{#if isEdit}}
{{input type="text" valueBinding="Name" name="Name"}}
{{else}}
<label class="category-text">{{#linkTo 'category' this}}{{Name}}{{/linkTo}}</label>
{{/if}}
<img class="table-img" src="images/x.png">
<img class="table-img" {{action 'edit'}} src="images/pencil-grey.png">
</td>
</tr>
{{/each}}
</tbody>
And then on the controller:
actions: {
edit:function(){
this.set('isEdit', true);
}
}
I am in the process of creating a new MVC v3 Razor web application and seem to be having issues in reading values from partial views.
I have a ViewModel (title) which is made up of three other ViewModels
public ProfileVM Profile { get; set; }
public SpecsVM Specs { get; set; }
public GeneralVM General { get; set; }
public Guid Id { get; set; }
I have a page which is strongly typed to the Title view model, on which I am using the #Html.RenderPartial syntax to render each of the other ViewModels (profile etc) to different partial view
This appears to be working correctly, but I would like only one button on the page to handle the posting of data, and want to capture the values entered by the user into the partial views.
Is this possible?
Thanks in advance
Generated HTML as requested of the form sections. I've not added the master page information
<form action="/Titles/Title/Edit/2bb75b02-9dd7-e011-971f-0003fffb8797" method="post">
<fieldset>
<h1>
Title Details</h1>
<form action="/Titles/Title/Edit/2bb75b02-9dd7-e011-971f-0003fffb8797" method="post">
<fieldset>
<p>
<input type="submit" value="Save" name="TitleGeneral"/>
</p>
<hr />
<table>
<tr>
<td class="editor-label" style="width: 150px;"><label for="TitleCode">Code</label>
</td>
<td class="editor-label">
<input class="text-box single-line" id="TitleCode" name="TitleCode" type="text" value="T00006" /> <span class="field-validation-valid" data-valmsg-for="TitleCode" data-valmsg-replace="true"></span>
</td>
<td rowspan="7"> <img src="../../../../Content/demoBF.jpg" width="150px" height="150px" /></td>
</tr>
<tr>
<td class="editor-label">
<label for="TitleName">Title</label>
</td>
<td class="editor-label">
<input class="text-box single-line" id="TitleName" name="TitleName" type="text" value="Beaches Of France" />
<span class="field-validation-valid" data-valmsg-for="TitleName" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="SubTitle">Sub Title</label>
</td>
<td class="editor-label"><input class="text-box single-line" id="SubTitle" name="SubTitle" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="SubTitle" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="SortingTitle">Sorting Title (If Different)</label>
</td>
<td class="editor-label">
<input class="text-box single-line" id="SortingTitle" name="SortingTitle" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="SortingTitle" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label"><label for="ShortTitle">Short or abbreviated title</label>
</td>
<td class="editor-label"><input class="text-box single-line" id="ShortTitle" name="ShortTitle" type="text" value="TRO1" />
<span class="field-validation-valid" data-valmsg-for="ShortTitle" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label"><label for="Comments">Comments</label>
</td>
<td class="editor-label">
<input class="text-box single-line" id="Comments" name="Comments" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Comments" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="Author">Author</label>
</td>
<td class="editor-label">
<input class="text-box single-line" id="Author" name="Author" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Author" data-valmsg-replace="true"></span>
</td>
</tr>
</table>
</fieldset>
</form> <br />
<br />
<ul class="tabs">
<li>Profile</li>
<li>Specification</li>
<li>Authors</li>
<li>Editions</li>
<li>Restrictions</li>
<li>Licences</li>
<li>Purchases</li>
<li>Restrictions</li>
</ul>
<div class="tab_container">
<div id="tab1" class="tab_content">
<!--Content-->
<form action="/Titles/Title/Edit/2bb75b02-9dd7-e011-971f-0003fffb8797" method="post">
<fieldset>
<p>
<input type="submit" value="Save" name="TitleProfile"/>
</p>
</fieldset>
</form> </div>
<div id="tab2" class="tab_content">
<!--Content-->
<form action="/Titles/Title/Edit/2bb75b02-9dd7-e011-971f-0003fffb8797" method="post">
<fieldset>
<table>
<tr>
<td class="editor-label" style="width: 150px;"><label for="Pages">Pages</label>
</td>
<td class="editor-label"><input class="text-box single-line" data-val="true" data-val-number="The field Pages must be a number." id="Pages" name="Pages" type="text" value="96" />
<span class="field-validation-valid" data-valmsg-for="Pages" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label"><label for="Plates">Plates or illustrations</label>
</td>
<td class="editor-label"><input class="text-box single-line" data-val="true" data-val-number="The field Plates or illustrations must be a number." id="Plates" name="Plates" type="text" value="64" />
<span class="field-validation-valid" data-valmsg-for="Plates" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="PlateType">Plate Type</label>
</td>
<td class="editor-label"><input class="text-box single-line" id="PlateType" name="PlateType" type="text" value="Full-colour photographs" />
<span class="field-validation-valid" data-valmsg-for="PlateType" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="Format">Format</label>
</td>
<td class="editor-label"><input class="text-box single-line" id="Format" name="Format" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Format" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="OtherSpecs">Other specifications</label>
</td>
<td class="editor-label">
<input class="text-box single-line" id="OtherSpecs" name="OtherSpecs" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="OtherSpecs" data-valmsg-replace="true"></span>
</td>
</tr>
</table>
</fieldset>
</form> </div>
<div id="tab3" class="tab_content">
<!--Content-->
<form action="/Titles/Title/Edit/2bb75b02-9dd7-e011-971f-0003fffb8797" method="post">
<fieldset>
<table>
<tr>
<td class="editor-label" style="width: 150px;"><label for="Pages">Pages</label>
</td>
<td class="editor-label"><input class="text-box single-line" data-val="true" data-val-number="The field Pages must be a number." id="Pages" name="Pages" type="text" value="96" />
<span class="field-validation-valid" data-valmsg-for="Pages" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label"><label for="Plates">Plates or illustrations</label>
</td>
<td class="editor-label"><input class="text-box single-line" data-val="true" data-val-number="The field Plates or illustrations must be a number." id="Plates" name="Plates" type="text" value="64" />
<span class="field-validation-valid" data-valmsg-for="Plates" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="PlateType">Plate Type</label>
</td>
<td class="editor-label"><input class="text-box single-line" id="PlateType" name="PlateType" type="text" value="Full-colour photographs" />
<span class="field-validation-valid" data-valmsg-for="PlateType" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="Format">Format</label>
</td>
<td class="editor-label"><input class="text-box single-line" id="Format" name="Format" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Format" data-valmsg-replace="true"></span>
</td>
</tr>
<tr>
<td class="editor-label">
<label for="OtherSpecs">Other specifications</label>
</td>
<td class="editor-label">
<input class="text-box single-line" id="OtherSpecs" name="OtherSpecs" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="OtherSpecs" data-valmsg-replace="true"></span>
</td>
</tr>
</table>
</fieldset>
</form> </div>
</div>
</fieldset>
</form><div>
Back to List
</div>
</td></tr>
</table>
The problem is that the names of the input fields are incorrect. They are missing the prefix indicating the main parent property name. That's due to trhe usage of partials instead of editor templates. Jimmy Bogard explained this perfectly in this blog post.
So instead of:
#Html.Partial("_somePartial", Model.Profile)
use:
#Html.EditorFor(x => x.Profile)
and the framework will take care of properly naming the fields.