Click here to Skip to main content
11,806,575 members (67,593 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET jQuery MVC3
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
Edited 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
0 ppolymorphe 205
1 OriginalGriff 175
2 Richard Deeming 175
3 Sergey Alexandrovich Kryukov 170
4 Abhinav S 120
0 OriginalGriff 3,380
1 Maciej Los 1,990
2 CPallini 1,915
3 KrunalRohit 1,907
4 ppolymorphe 1,317

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 22 Jun 2012
Copyright © CodeProject, 1999-2015
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