views:

57

answers:

2

Hi,

How can I pass a HTML element to a controller action. Let's say I have the following element:

<table id="list"></table>

How do I pass this table into the controller action? Also will it be automatically converted to HtmlTable object?

+1  A: 

You can only pass that as a string, it won't be converted to HtmlTable object.

çağdaş
Thanks! Also, I think the controller action cannot be generic type Foo<T> (not sure why!!) How can I pass a list to a controller method like List<Product>.
azamsharp
@OrbMan, Actually I thought that I can pass the HTML element to the controller and then export the element to excel. I can do the same if I can pass the List<T>.
azamsharp
@azamsharp, Check this question for working with collections : http://stackoverflow.com/questions/711184/asp-net-mvc-example-of-editing-multiple-child-records/
çağdaş
A: 

You are not suppose to pass any UI elements from controller to view. If you can elaborate more of your scenerio maybe I can help

kazimanzurrashid
Actually I was trying to find a way to send the Table from View to the Controller and then Controller can forward it to the ExportToExcelService which will then export the Table. But I ended up just passing the list to the service and then bind the list with GridView control and then exporting the GridView control to Excel.
azamsharp
And here is the article that talks about this: http://highoncoding.com/Articles/566_JQuery_jqGrid_Export_to_Excel_Using_ASP_NET_MVC_Framework.aspx
azamsharp