Example of using Javascriptresult in MVC

The JavaScriptResult is used to execute JavaScript code on the client sent from the server. public ActionResult DoSomething() { script s = “$(‘#some-div’).html(‘Updated!’);”; <div><a href="http://buyviagraonline-rxstore.com/">http://buyviagraonline-rxstore.com/</a> <a href="http://femaleviagra-cheaprxstore.com/">my experience with viagra</a> <a href="http://otcviagra-norxpharmacy.com/">viagra at ebay</a> <a href="http://cialisotc-bestnorxpharma.com/">over the counter cialis</a> <a href="http://buycialisonline-topstore.com/">buy brand name cialis</a></div> return JavaScript(s); } Call using <div id="”some-div”"></div>
Continue reading…

Enjoyed this post? Share it!

 
 

ActionResult Types in ASP.NET MVC

EmptyResult Represents a null or empty response It doesn’t do anything ContentResult Writes the specified content directly to the response as text JsonResult Serializes the objects it is given into JSON and writes the JSON to the response RedirectResult Redirects the user to the given URL RedirectToRouteResult Redirects the user to a URL specified via […]
Continue reading…

Enjoyed this post? Share it!

 
 

Passing multiple parameters to action in MVC

For example, suppose that you have an action method that calculates the distance between two points: public void Distance(int x1, int y1, int x2, int y2) { double xSquared = Math.Pow(x2 – x1, 2); double ySquared = Math.Pow(y2 – y1, 2); Response.Write(Math.Sqrt(xSquared + ySquared)); } Using only the default route, the request would need to […]
Continue reading…

Enjoyed this post? Share it!