103 articles ASP.NET MVC Page 3 / 11

MVC Default Validation Message

Default validation message di MVC [code language=”csharp”] [ArgumentIsNullOrWhitespace, The argument ‘{0}’ cannot be null, empty or contain only white space.] [AssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties, The associated metadata type for type ‘{0}’ contains the following unknown properties or fields: {1}. Please make sure that the names of these members match the names of the properties on the main type.]…

Visual Studio Rename Project

Tahapan me-rename project (folder dan namespace) pada Visual Studio To rename a project’s folder, file (.*proj) and display name in visual studio: Close the solution. Rename the folder(s) outside Visual Studio. (Rename in TFS if using source control) Open the solution, ignoring the warnings (answer “no” if asked to load a project from source control).…

Web API Basic Authorization

Salah satu alternatif untuk mengamankan Web API adalah dengan Basic Authorization. Jika kita sudah menyiapkan sesuai petunjuk pada referensi [1], berikutnya kita tinggal menambahkan tag [Authorize] pada Web API Controller. [code language=”csharp”] [Authorize] public class OperationController : ApiController { //… } [/code] Setting Basic Authorization pada DHC. Klik “set an authorization” Isi username dan password…

Kendo UI Datepicker / DateTimePicker Disable Typing

Membuat field Kendo Datepicker / DateTimePicker tidak bisa di input melalui keyboard. Tinggal menambahkan attribut onkeydown. Contoh penggunaan pada form.cshtml [code language=”html”] <input id="StartDate" onkeydown="return false"/> <!–atau–> @Html.EditorFor(model =&gt; model.StartDate, new { htmlAttributes = new { @onkeydown = "return false" } }) [/code]

Menambahkan no urut pada kendo grid

Menmabhakan no urut di kolom dapat dilakukan tanpa menggunakan model [code language=”javascript”] var record = 0; $("#grid-loan").kendoGrid({ dataSource: dataSourceMyLoan, pageable: true, sortable: true, filterable: kendoGridFilterableUSWithoutRow, resizable: true, dataBinding: function() { record = (this.dataSource.page() -1) * this.dataSource.pageSize(); }, columns: [{ field: "Id", hidden: true, }, { title: "No", template: "#= ++record #", width: 40 }, [/code]