0

I am using devExpress controlls and I have code like this:

settings.ClientSideEvents.RowDblClick = "myJavascriptFunction";

and that mean that when I double click on control it invoke javascript function myJavascriptFunction. I have controller like this:

public class MyController : Controller
{
    //
    // GET: /My/

    public ActionResult Index(string a,string b)
    {
        return View();
    }
}

I want to call that controller method from my javascript.

I read Calling ASP.NET MVC Action Methods from JavaScript

and How to call a Controller method from javascript in MVC3? and more...

but all suggest ajax call and I want to render the whole page to my controller... someone know how to achieve this?

1 Answer 1

1

Assuming you mean to just redirect them (no AJAX):

function myJavascriptFunction(){
  var a = 'foo', // to parameters of Index
      b = 'bar';
  window.location = '/My/Index'
      + '?a=' + encodeURIComponent(a)
      + '&b=' + encodeURIComponent(b);
}

Otherwise " I want to render the whole page to my controller. " is a little too vague. Please revise the question and be more specific and I'll adjust my answer.

Sign up to request clarification or add additional context in comments.

2 Comments

and how to pass string a and string b?
@ilayzeidman: '/My/Index?a=' + encodeURIComponent(a) + '&b=' + encodeURIComponent(b);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.