Chandra Oemaryadi has written 244 articles

DevExpress Grid Show Data from One to Many

Kasus: project memiliki relasi one-to-many terhadap history_afe. Pada tabel ingin ditampilkan data status yang merupakan status project terakhir dari tabel history_afe. ASPX [code language=”aspx”] <dx:GridViewDataTextColumn FieldName="Status" VisibleIndex="30" Caption="Status"> <Settings AllowAutoFilter="False" AllowSort="False" /> <DataItemTemplate> <dx:ASPxLabel ID="LastStatus" runat="server" OnInit="LastStatus_Init"></dx:ASPxLabel> </DataItemTemplate> </dx:GridViewDataTextColumn> [/code] C# [code language=”csharp”] protected void LastStatus_Init(object sender, EventArgs e) { DevExpress.Web.ASPxEditors.ASPxLabel label = (DevExpress.Web.ASPxEditors.ASPxLabel)sender; GridViewDataItemTemplateContainer…

ASP MVC Error Could not load file or assembly … The parameter is incorrect

Sesudah laptop bluescreen, ketika me-run aplikasi ASP MVC muncul error Could not load file or assembly … The parameter is incorrect. Solusinya dengan menghapus file di: \bin C:\Users\your_username\AppData\Local\Temp\Temporary ASP.NET Files in windows 7) http://stackoverflow.com/questions/8269386/could-not-load-file-or-assembly-the-parameter-is-incorrect

Kendo ComboBox Cascading

Pada ComboBox Cascading, ada 2 combobox: parent dan child. Isi combobox child ditentukan oleh pilihan user pada combobox parent. [code language=”html”] <div class="form-group"> @Html.LabelFor(model => model.GroupId, new { @class = "col-xs-2 control-label" }) <div class="col-xs-4"> @Html.TextBoxFor(model => model.GroupId, new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.FullName) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.DepartmentId, new…

ASP MVC Remove Validation

Berikut contoh penggunaan remove validation pada model di ASP MVC. Remove validation hanya berfungsi jika fungsi client side validation diaktifkan. [code language=”csharp”] [Remote("CheckForUniqueEmail", "Membership", "SecurityGuard", AdditionalFields="User.UserName", ErrorMessage = "This {0} is already used.")] public string Email { get; set; } [/code] [code language=”html”] <div class="form-group"> @Html.LabelFor(model => model.Email, new { @class = "col-xs-2 control-label" })…

ASP Add Callback to jQuery Form Validation on Invalid

Fungsi untuk menangani callback setelah terjadi error pada validasi form client side menggunakan jQuery [code language=”javascript”] $(‘#main-form’).bind(‘invalid-form.validate’, function () { $(‘form button, form input[type=submit]’).removeAttr(‘disabled’); }); [/code] main-form adalah id dari form yang divalidasi. http://stackoverflow.com/questions/3873534/how-can-i-add-callbacks-to-jquery-validation-when-used-in-mvc-2

ASP.NET MVC Security Guard Membership using Profile for Additional User Data

Kita dapat menambahkan data user yang secara default disediakan oleh Security Guard / Membership. Misalnya kita mau menambahkan data nama lengkap user. Untuk menambahkan data tersebut, kita dapat menggunakan fitur Profile yang disediakan Membership. 1. Buat kelas profile yang berisi data-data tambahan user [code language=”csharp”] namespace WebUI.Models { public class UserProfile : ProfileBase { [SettingsAllowAnonymous(false)]…

ASP MVC Create Full URL in Controller

Menghasilkan full url di dalam Controller MVC [code language=”csharp”] string address = Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority + Url.Action("Detail", "IncomingDocument", new { id = form.Id }); [/code] Contoh hasilnya: http://localhost:3750/IncomingDocument/Detail/16 http://stackoverflow.com/questions/699782/creating-a-url-in-the-controller-net-mvc

Kendo UI Combobox

Contoh penggunaan Kendo UI Combobox, dengan mewajibkan user memilih salah satu nilai yang valid dari Combobox. [code language=”javascript”] function comboBoxOnChange(e){ if (this.value() && this.selectedIndex == -1) { //or use this.dataItem to see if it has an object this.text(”); } } $(‘#Disposition1Email’).kendoComboBox({ dataTextField: "Text", dataValueField: "Value", autoBind: false, dataSource: { data: @Html.Raw(Model.GetAssigneeOptionsAsJson()) }, change : comboBoxOnChange,…

Kendo UI AutoComplete Example

Contoh kode javascript menggunakan Kendo UI AutoComplete [code language=”javascript”] var assigneeValid = false; $("#Assignee").kendoAutoComplete({ placeholder: "Silakan Pilih", dataTextField: "Text", filter: "contains", minLength: 2, dataSource: new kendo.data.DataSource({ data: @Html.Raw(Model.GetAssigneeOptionsAsJson()) }), open: function(e){ assigneeValid = false; }, select: function (e) { var item = e.item; var dataItem = this.dataItem(e.item.index()); $("#Assignee").val(dataItem.Text); assigneeValid = true; }, close: function(e){ if(!assigneeValid)…