如何从视图发送HTML表控制器mvc4 [英] how to send html table from view to controller in mvc4

查看:162
本文介绍了如何从视图发送HTML表控制器mvc4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从视图发送HTML表控制器。
我有鉴于表,其中即时通讯在网格中显示我的数据现在我要送在HTML文件中此网格数据controller.i达到到这里我创建表的HTML文件,我必须将此文件发送给控制器。

 < HTML>
<表>
&所述; TR>&下; TD> 12下; TD>&下; / TR>
< /表>
< / HTML>
VAR请求= $阿贾克斯({
                网址:'?..controllername / actionname htmlTableValue'+ htmlTableValue,//动作方法这在控制器定义的URL
                输入:POST,
                缓存:假的,
                数据:JSON.stringify(htmlTableValue)
                数据类型:JSON,
                的contentType:应用/ JSON的;字符集= UTF-8
            });
[HttpPost]
        公众的ActionResult nameOfTheAction(字符串htmlTableValue)
        {
        }

达到空值控制器
它失败
将数据发送到CONTROLER


解决方案

  VAR htmlTableValue =< HTML>
<表>
&所述; TR>&下; TD> 12下; TD>&下; / TR>
< /表>
< / HTML>中;VAR请求= $阿贾克斯({
                网址:'',//这在控制器中定义的操作方法网址
                输入:POST,
                缓存:假的,
                数据:JSON.stringify(htmlTableValue)
                数据类型:JSON,
                的contentType:应用/ JSON的;字符集= UTF-8
            });`输入code here`

How to send HTML table from view to controller. i have table in view where i m displaying my data in grid now i have to send this grid data in HTML file to controller.i reach till here i created HTML file of my table and i have to send this file to controller.

<HTML>
<table>
<tr><TD> 12 <TD></tr>
</table>
</HTML>


var request = $.ajax({
                url: '..controllername/actionname?htmlTableValue'+htmlTableValue,//action method url which defined in controller
                type: 'POST',
                cache: false,
                data: JSON.stringify(htmlTableValue),
                dataType: 'json',
                contentType: 'application/json; charset=utf-8'
            });


[HttpPost]
        public ActionResult nameOfTheAction(string htmlTableValue)
        {
        }

reaching null values to controller where it fails to send data to controler

解决方案

var htmlTableValue = "<HTML>
<table>
<tr><TD> 12 <TD></tr>
</table>
</HTML>";

var request = $.ajax({
                url: '',//action method url which defined in controller
                type: 'POST',
                cache: false,
                data: JSON.stringify(htmlTableValue),
                dataType: 'json',
                contentType: 'application/json; charset=utf-8'
            });`enter code here`

这篇关于如何从视图发送HTML表控制器mvc4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆