Click here to Skip to main content
13,150,178 members (55,215 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a view that changes content without changing the overall view,
(change a portion of the view)
here is my code:

public class DisplayData
        public int ID { get; set; }
        public DisplayData(int ID)
            this.ID = ID;


public ActionResult PartialDemo(string Data)
            List<DisplayData> Display = new List<DisplayData>();
            if (Request.IsAjaxRequest())
                if (Data == "1")
                    Display.Add(new DisplayData(3));
                    Display.Add(new DisplayData(4));
                    Display.Add(new DisplayData(5));
                    Display.Add(new DisplayData(6));
                return PartialView("PartialDemoUC", Display);
                Display.Add(new DisplayData(1));
                Display.Add(new DisplayData(2));
                return View("PartialDemo", Display);

@model IEnumerable<dynamic>
@foreach(var items in Model)


@model IEnumerable<AppTwitter.Models.DisplayData>
    ViewBag.Title = "PartialDemo";
<script src="../../Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
@Ajax.ActionLink("Link_1", "PartialDemo", "PartialDemo", new {Data= "1" }, new AjaxOptions { UpdateTargetId = "rsvpmsg" })
@Ajax.ActionLink("Link_2", "PartialDemo", "PartialDemo", new {Data= "2" }, new  AjaxOptions { UpdateTargetId = "rsvpmsg" })
<div id="rsvpmsg">
@{ Html.RenderPartial("PartialDemoUC", this.Model);}

I will change Link_1 and Link_2 by a checkbox: if chechbox is checked it's like the link is clicked
how can i do this ?

I am sorry for my bad english

Posted 21-Jun-12 22:18pm
Updated 21-Jun-12 22:38pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Basically, you want to use jQuery to watch the click event on the checkbox. When it is clicked, you want to have the jQuery method call your MVC method with the appropriate parameters. Here is a Stack Overflow question that has an example of how to do this in the given answer:[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170924.2 | Last Updated 22 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100