将控制从文件上传控制传递到控制器的问题 [英] Question on passing control from file upload control to controller

查看:78
本文介绍了将控制从文件上传控制传递到控制器的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图创建一个文件控件,当用户选择.csv文件时,我打算将csv文件的内容写入字符串。

我已经把你的博客,在ASP.net MVC上传和返回文件

我有一个文件上传控件,

Hi,
I have attempted to create a file control and when user selects a .csv file, I intent to write the contents of csv file to a string.
I have taken your blog, Uploading and returning files in ASP.net MVC
I have a file upload control,

<input type = "file" onchange = "ProcessCsv()" />





我在我的控制器中定义了一个动作结果



I defined an action result in my controller

[HttpPost]
public ActionResult ProcessCsv(HttpPostedFileBase file)
{
  // Need to read the csv file into a string
}



我收到错误消息, 参考错误:ProcessCsv()未定义。



如何将控件从html传递给动作结果?



提前致谢


I get an error saying, "Reference Error: ProcessCsv() is not defined".

How do I pass the control from html to an action result?

Thanks in advance

推荐答案

<input type = "file" onchange = "ProcessCsv()" />



您的控件定义如下客户端HTML控件。因此,任何定义的事件都会尝试在脚本中找到它在客户端处理的方法。



只有服务器控件才会引发或引用服务器端事件。


Your control definition looks like a client side HTML control. Thus any event defined will try to find it''s method handled on client side in scripts.

Only server controls will raise or refer to server side events.


这篇关于将控制从文件上传控制传递到控制器的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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