Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

pathllk

@pathllk
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • FILL HTML.EDITFOR FIELDS ON BUTTON CLICK IN ASP.NET MVC
    P pathllk

    Dear Friends I am new MVC world & working in a project. I want to fill some html.editfor fields on a button click. My tried the given below codes: Controller action:

    [HttpPost]
    public JsonResult GetRecordById(string id)
    {
    var record = dc.TABLE1.FirstOrDefault(x => x.PART_NO == id);
    var result = new
    {
    Name = record.PARTI,
    Type = record.TYPE
    };
    return Json(result, JsonRequestBehavior.AllowGet);
    }

    VIEW:

    <script type="text/javascript">
    $(function () {
    $("#txtParti").autocomplete({
    source: '@Url.Action("GetParti")'
    });
    });
    $(function () {
    $("#txtPtno").autocomplete({
    source: '@Url.Action("GetPtno")'
    });
    });
    $('#BTNFET').onclick(function (fetrec) {
    var recordId = this.value;
    $.post('@Url.Action("GetRecordById")',
    {
    "id": recordId
    },
    function (data) {
    $("#txtParti").val(data.Name);
    $("#Type").val(data.Type);
    });
    });
    </script>

    <input type="button" id="BTNFET" onclick="fetrec();" />
    @Html.EditorFor(model => model.PARTI, new { htmlAttributes = new { @class = "form-control", @id = "txtParti", @placeholder = "PART NAME" } })
    @Html.EditorFor(model => model.PART_NO, new { htmlAttributes = new { @class = "form-control", @id = "txtPtno", @placeholder = "PART NO" } })
    @Html.EditorFor(model => model.TYPE, new { htmlAttributes = new { @class = "form-control", @id = "Type", @placeholder = "ITEM TYPE" } })

    On the above codes Auto complete part working pefectly, Button click not working. So, friends please help me in this regard.

    ASP.NET asp-net csharp javascript html tools
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups