103 articles ASP.NET MVC Page 4 / 11

Table in Form

Terkadang kita memerlukan tabel di dalam form, misalnya untuk kasus data one-to-many. Salah satu alternatif solusinya dapat menggunakan Kendo Grid. CREATE InvoiceFormStub.cs [code language=”csharp”] public class InvoiceFormStub { //… public List<InvoiceItemFormStub> AdditionalItem { get; set; } [DisplayName("Tambahan Item")] public string AdditionalItemText { get; set; } //… } [/code] Form.cshtml [code language=”csharp”] <div class="form-group"> @Html.LabelFor(model =>…

Rotativa Windows Server

Waktu menjalankan Rotativa di Windows Server Pertamina, muncul error. Rotativa yang digunakan dari NuGet versi 1.6.4. Solusinya dengan mengganti wktohtml library pada folder Rotativa dengan versi 1.6.3. Bisa di-download di https://drive.google.com/file/d/0BzI_u_O3vUM1aEppb3ZVZXNsc28/view https://github.com/webgio/Rotativa/issues/23

Kendo Grid with Checkbox

Kendo Grid memiliki kolom checkbox. Waktu di-submit, data yang di-check dikirim ke server. [code language=”javascript”] relatedManufacturer = $(".relatedManufacturer-tree").kendoGrid({ dataSource: manufacturers, filterable: kendoGridFilterable, columns: [ { template: "<input type=’checkbox’ class=’checkbox’ #= (checked === true) ? ‘checked’ : ” # />", width: 50, filterable: false, sortable: false }, { field: "Title", expandable: true, title: "Nama" }, ],…

Rotativa

Install Rotativa menggunakan NuGet Pilih yang dibuat oleh Giorgio Bozio. Contoh: [code language=”csharp”] [HttpPost] public ActionResult Download(ManufacturerDownloadFormStub model) { List<int> subcategoryId = model.GetSubcategoryIdArray(); DisplayFormatHelper dfh = new DisplayFormatHelper(); return new Rotativa.ActionAsPdf("ManufacturerPdf", new { subcategoryId = model.SubcategoryIdString }) { FileName = "AML (" + DateTime.Now.ToString(dfh.FullDateFormat) + ").pdf", PageOrientation = Rotativa.Options.Orientation.Portrait, PageSize = Rotativa.Options.Size.A4, CustomSwitches = string.Format("–footer-right…

Compare Database Changes using Visual Studio

Kita dapat membandingkan 2 database, lalu menerapkan perbedaan menggunakan fasilitas dari Visual Studio. 1. Buat proyek baru dengan tipe SQL Server Database Project 2. Import database Klik “New Connection”. Di bagian ini memilih database dengan skema baru. 3. Compare dengan skema lama Isi Connection dengan skema lama (yang ingin diubah menggunakan skema baru). 4. Sesuaikan…

Powershell Command : Rekadia Template Generator

Untuk semua project, mohon pergunakan project template yang terdapat di http://rekadia.net/gitrepo/Repository/rekadia-template. Untuk menggunakan code template generator, terlebih dahulu sudah terdapat entities yang mau dibuat. Kemudian, tekan ‘VIEWS’ –> ‘Other Window’ –> ‘Package Manager Console’. Pada window ‘Package Manager Console’, masukkan command-command berikut.   Command membuat repository: scaffold EntitiesRepo <entity class name> -Project Business -DbContextType <DbContext…

Upload Files with HTTPWebRequest and Web API

Contoh kode untuk mengirim file menggunakan HTTPWebReqeust. Jika bukan MVC, dapat meng-add Microsoft.Net.Http pada NuGet. Kode di bagian pengiriman file [code language=”csharp”] public string HttpPost(string url, string fileName, byte[] fileByte, string username) { ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); HttpContent fileNameContent = new StringContent(fileName); HttpContent usernameContent = new StringContent(username == null ? "" : username); HttpContent fileContent…

ASP.NET Web Forms and MVC Bypass Authorization for Single Form or Single Controller using web.config

Jika penanganan authorization menggunakan web.config, authorization dapat di by pass untuk form tertentu / controller tertentu. “Api/File” adalah url untuk memanggil controller (MVC / Web API). “service/FileService.aspx” adalah struktur folder/file ke form. [code language=”xml”] <configuration> <location path="Api/File"> <system.web> <authorization> <allow users="?"></allow> </authorization> </system.web> </location> <location path="service/FileService.aspx"> <system.web> <authorization> <allow users="?"></allow> </authorization> </system.web> </location> <system.web> <authentication…

“Add Area” not Appeared in Visual Studio 2013

Step 1) : Go to your solution explorer and unload the existing ASP.NET project by right clicking and selecting “Unload Project” Step 2) Right Click the Project in solution explorer and select “Edit ….csproj“ Step 3) Go to the Element called “ProjectTypeGuids” and change the content to. [code language=”xml”] <ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> [/code] Save the file and…