?
Solved

Updating HTML using c# razor syntax

Posted on 2014-04-29
2
Medium Priority
?
284 Views
Last Modified: 2014-05-13
I currently have a div class 'updatedContent' that is populated from the results of a razor HTML action "@Html.Action("test", "test2", new { isEditable = false }) my solution is in .net MVC 4.0 and I am looking at using something like jquery .load() or Ajax.

At the moment this gets populated on load but what I need is for this to get triggered as part of an on click event on a button.

I am familiar with jquery but not using it with c# and razor syntax.

Please can someone help?

Thanks
0
Comment
Question by:Al4ddin2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:Al4ddin2
ID: 40029920
Any ideas from anyone? Sorry to pester

Thanks
0
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 2000 total points
ID: 40031215
Hi,

Lets say you have a GET method called MyGet on your Controller.

You also need to give an ID, ie "Results" on your div.

In your View have the following where you want your button:

@using(Ajax.BeginForm("MyGet", new AjaxOptions { UpdateTargetId = "Results", InsertionMode = InsertionMode.Replace, HttpMethod = "Get" }))
{
    <input type="submit" value = "Refresh" />
}

Open in new window


Giannis
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question