farzinmonsef / WBRS

0 stars 0 forks source link

MVC UpdatePanel #8

Open farzinmonsef opened 6 years ago

farzinmonsef commented 6 years ago

MVC UpdatePanel

farzinmonsef commented 6 years ago

How to make update panel in ASP.NET MVC

https://stackoverflow.com/questions/961612/how-to-make-update-panel-in-asp-net-mvc

farzinmonsef commented 6 years ago

Emulating the UpdatePanel in ASP.NET MVC 1.0 with AjaxHelper

https://weblogs.asp.net/dwahlin/emulating-the-updatepanel-in-asp-net-mvc-1-0-with-ajaxhelper

farzinmonsef commented 6 years ago

Updatepanel in mvc how to get content with a ajax call

https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/47362-Updatepanel-in-mvc-how-to-get-content-with-a-ajax-call

farzinmonsef commented 6 years ago

How to Use Ajax.BeginForm

Code Project https://www.codeproject.com/Tips/871347/How-to-Use-Ajax-BeginForm

AdminTool.zip

farzinmonsef commented 6 years ago

Walkthrough: Adding ASP.NET AJAX Scripting to an MVC Project

https://msdn.microsoft.com/en-us/library/dd381533%28v=vs.100%29.aspx

farzinmonsef commented 6 years ago

ASP.NET MVC Ajax.BeginForm AjaxOptions OnSuccess, OnFailure

http://www.c-sharpcorner.com/article/asp-net-mvc-5-ajax-beginform-ajaxoptions-onsuccess-onfailure/

Ajax_Option_Function.zip

farzinmonsef commented 6 years ago

Kendo Grid Refresh

https://www.telerik.com/forums/how-to-reload-grid

$("#grid").data("kendoGrid").dataSource.read();

$("#grid").data("kendoGrid").dataSource.sync();

farzinmonsef commented 6 years ago

Refresh Kendo Grid = By Search

Multiple Ways To Bind Data To Kendo Grid In MVC

http://www.c-sharpcorner.com/article/multiple-ways-to-bind-data-to-kendo-grid-in-mvc/

farzinmonsef commented 6 years ago

Refresh Kendo Grid = By Search - 1/3

@model Kendo_Ajax_BeginForm.Models.Company @using System.Web.Optimization @using Kendo.Mvc.UI @using Kendo.Mvc.Extensions @{ Layout = "~/Views/Shared/_Layout.cshtml"; }

@



@(Html.Kendo().TextBoxFor(model => model.CompanyId) .Name("CompanyId") .HtmlAttributes(new { placeholder = "Search By Company Id", @autocomplete = "off", @class = "col-sm-12", style = "width:100%", maxlength = 200 }) )





@(Html.Kendo().Grid() .Name("BindGridUsingRead") .Columns(columns => { columns.Bound(p => p.Id).Width(15).Title("Sr. No.").Filterable(false); columns.Bound(p => p.Name).Title("Name").Width(30).Filterable(false).ClientTemplate("#=Name#"); //columns.Bound(p => p.Name).Title("Name").Width(30).Filterable(false).ClientTemplate("#=Name #"); columns.Bound(p => p.CompanyId).Title("Company Id").Width(15).Filterable(false); //columns.Bound(c => c.Id).Width(150) // .ClientFooterTemplate("
"); }) .Scrollable() //.Pageable(x => x.PageSizes(new List { 10, 20, 100, 200, 500, "all" }).Refresh(true)) .Filterable(ftp => ftp.Mode(GridFilterMode.Row)) .Resizable(resize => resize.Columns(true)) .HtmlAttributes(new { style = "Width: 400px"})//, @class="k-grid-footer" .Selectable() //.Pageable() .Scrollable(a => a.Height("auto")) .DataSource(dataSource => dataSource .Ajax() .Model(model => model.Id(p => p.Id)) .ServerOperation(false) .Read( read => read.Action("BindGrid", "Company") ) ) )

@@(Html.Kendo().Grid() .Name("grid") .Columns(columns => { columns.Bound(c => c.CategoryName); columns.Bound(c => c.Description); columns.Bound(c => c.Picture); }) .Scrollable() .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("Categories_Read", "Company")) ) )@

farzinmonsef commented 6 years ago

Refresh Kendo Grid = By Search - 2/3

using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net; using System.Web; using System.Web.Mvc; using Kendo.Mvc.Extensions; using Kendo.Mvc.UI; using Kendo_Ajax_BeginForm;

namespace Kendo_Ajax_BeginForm.Controllers { public class CompanyController : Controller { private northwindEntities db = new northwindEntities();

    public ActionResult Index()
    {
        return View();
    }

    public ActionResult BindGrid([DataSourceRequest]DataSourceRequest request)
    {
        try
        {
            decimal companyId = 0;
            List<Models.Company> lst = new List<Models.Company>();
            lst = GetGridData(Convert.ToInt32(companyId)).ToList();
            DataSourceResult result = lst.ToDataSourceResult(request, p => new Models.Company
            {
                Id = p.Id,
                Name = p.Name,
                CompanyId = p.CompanyId,
            });
            return Json(result, JsonRequestBehavior.AllowGet);
        }
        catch (Exception ex)
        {
            var errorMsg = ex.Message.ToString();
            return Json(errorMsg, JsonRequestBehavior.AllowGet);
        }
    }
    public IEnumerable<Models.Company> GetGridData(decimal companyId)
    {
        List<Models.Company> objCmp = new List<Models.Company>();
        List<Models.Company> listCompany = new List<Models.Company>();
        objCmp.Add(new Models.Company() { Id = 1, Name = "Rupesh Kahane", CompanyId = 20 });
        objCmp.Add(new Models.Company() { Id = 2, Name = "Vithal Wadje", CompanyId = 40 });
        objCmp.Add(new Models.Company() { Id = 3, Name = "Jeetendra Gund", CompanyId = 30 });
        objCmp.Add(new Models.Company() { Id = 4, Name = "Ashish Mane", CompanyId = 15 });
        objCmp.Add(new Models.Company() { Id = 5, Name = "Rinku Kulkarni", CompanyId = 18 });
        objCmp.Add(new Models.Company() { Id = 6, Name = "Priyanka Jain", CompanyId = 22 });
        if (companyId > 0)
        {
            listCompany = objCmp.ToList().Where(a => a.Id==companyId).ToList();
            return listCompany.AsEnumerable();
        }
        return objCmp.ToList().AsEnumerable();
    }
    public ActionResult BindGridOnSearch([DataSourceRequest]DataSourceRequest request, string companyId)
    {
        try
        {
            List<Models.Company> list = new List<Models.Company>();
            list = GetGridData(Convert.ToInt32(companyId)).ToList();
            DataSourceResult result = list.ToDataSourceResult(request, p => new Models.Company
            {
                Id = p.Id,
                Name = p.Name,
                CompanyId = p.CompanyId,
            });
            return Json(result, JsonRequestBehavior.AllowGet);
        }
        catch (Exception ex)
        {
            var errorMsg = ex.Message.ToString();
            return Json(errorMsg, JsonRequestBehavior.AllowGet);
        }
    }
    public ActionResult Categories_Read([DataSourceRequest]DataSourceRequest request)
    {
        IQueryable<Category> categories = db.Categories;
        DataSourceResult result = categories.ToDataSourceResult(request, category => new {
            CategoryID = category.CategoryID,
            CategoryName = category.CategoryName,
            Description = category.Description,
            Picture = category.Picture,
        });

        return Json(result);
    }

    protected override void Dispose(bool disposing)
    {
        db.Dispose();
        base.Dispose(disposing);
    }
}

}

farzinmonsef commented 6 years ago

Refresh Kendo Grid = By Search - 3/3

using System; using System.Collections.Generic; using System.Linq; using System.Web;

namespace Kendo_Ajax_BeginForm.Models { public class Company { public int Id { get; set; } public string Name { get; set; } public int? CompanyId { get; set; } } }