0

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?

azamsharp
  • 19,710
  • 36
  • 144
  • 222
  • The view should be responsible for presentation, not the controller, so it is possible that You Are Doing It Wrong. What are you trying to accomplish? – D'Arcy Rittich May 28 '09 at 18:06

2 Answers2

1

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

Çağdaş Tekin
  • 16,592
  • 4
  • 49
  • 58
  • Thanks! Also, I think the controller action cannot be generic type Foo (not sure why!!) How can I pass a list to a controller method like List. – azamsharp May 28 '09 at 18:05
  • @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. – azamsharp May 28 '09 at 18:06
  • @azamsharp, Check this question for working with collections : http://stackoverflow.com/questions/711184/asp-net-mvc-example-of-editing-multiple-child-records/ – Çağdaş Tekin May 28 '09 at 18:16
0

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

Kazi Manzur Rashid
  • 1,544
  • 13
  • 14
  • 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 May 30 '09 at 00:01
  • 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 May 30 '09 at 00:02