I have a button in one of my WebGrid columns. If the button is clicked, I am popping up a window using the following code:

window.open('/Home/Message', '_blank', 'toolbar=yes, scrollbar=yes, resizable=yes, top=500, left=500, width=400, height=400');

"Message" is another view that I have created that fills the popup window. I need to be able to pass the row object into that window for that particular button press. I assume there is a way to do that.

This is my Message ActionResult:

public ActionResult Message()
    {
        var model = new MessageViewModel();
        return View(model);
    }

But I really want to have a parameter on that method for the row object.

EDIT: More details.

So I have a button in my webgrid column like so:

grid.Column(header: "Fault", format: (item) =>
            {
                if (item.Fault != null)
                {
                    return new HtmlString("<input type='submit' id='btnShowFault' value='Fault' />");
                }

                return "";
            }))

And here is the javascript to that is called when it is clicked:

 $(function () {
    $("#btnShowFault").click(function (e) {
        e.preventDefault();

        window.open('/Home/Message', '_blank', 'toolbar=yes, scrollbar=yes, resizable=yes, menubar=no, top=200, left=500, width=400, height=250');
    });
});

So I guess what I really needs is two fold.

  1. How to get the row item from the grid into that function.
  2. How to pass that into the window.open call.

I assume this is possible as this is really easy to do in things like wpf and silverlight.

Related posts

Recent Viewed