jQuery弹出窗口中的fileupload控制问题 [英] Problem with fileupload control in jquery popup

查看:72
本文介绍了jQuery弹出窗口中的fileupload控制问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是Asp.net mvc的新手.所以我需要一些帮助.

在我的项目中,有一个名为programlist的视图,其中有一个链接"Add Program".当我们单击该链接时,我正在使用jquery将部分视图显示为弹出窗口.
在该局部视图中,有一个文件上载控件和一些文本框控件.当用户单击保存"按钮时,我编写了此代码.

Hi all,

I am new to Asp.net mvc. so i need some help.

In my project there is a view called programlist, in that there is a link "Add Program". When we click on that link i am showing a partial view as popup using jquery.
In that partial view there is one fileupload control and some textbox controls are there. when user clicks the save button then i wrote this code.

$("#frmadd").submit();



这里frmadd 是Partialview中表单的ID.

当提交该表单时,将执行一个返回类型为jsonresult的操作方法.现在,我想在脚本中捕获该json结果,但是它将在浏览器中以打开/保存"对话框打开.
现在我该怎么做才能在脚本中捕获该结果.

请帮助我.



here frmadd is id of the form in partialview.

when that form is submitted a action method with return type as jsonresult will get executed.Now i want to catch that json result in script, but it is opening as "Open/Save" Dialog in browser.
Now what should i do to catch that result in script.

Please help me.

推荐答案

(" ).submit();
("#frmadd").submit();



这里frmadd 是Partialview中表单的ID.

当提交该表单时,将执行一个返回类型为jsonresult的操作方法.现在,我想在脚本中捕获该json结果,但是它将在浏览器中以打开/保存"对话框打开.
现在我该怎么做才能在脚本中捕获该结果.

请帮助我.



here frmadd is id of the form in partialview.

when that form is submitted a action method with return type as jsonresult will get executed.Now i want to catch that json result in script, but it is opening as "Open/Save" Dialog in browser.
Now what should i do to catch that result in script.

Please help me.


指定动作后,该动作将被执行,并且动作结果(ActionResult或JsonResult)应将响应发送回去.请参见以下示例.
为用户提供了两个收音机:添加/替换"和添加".删除图像.当用户选择其中一个选项并选择上传文件时,单击按钮将在控制器中调用"SaveMyImage"操作.
When you have specified an action, the action gets executed and the action results(ActionResult or JsonResult) should send response back. See below example.
User is provided two radios: Add/Replace & Delete Image. When user selects either option and select upload file then click on button will call "SaveMyImage" action in the controller.
  <form id="frmImg" action="@Url.Action("SaveMyImage")" method="post" enctype="multipart/form-data">
  <table>
    <tr>
     <td>
         <input type="radio" name="addReplaceImage" value="1" checked="checked"/>Add/Replace Image<br />
     <input type="radio" name="addReplaceImage" value="2"/>Delete Image
    </td>
  </tr>
     <tr>
       <td><input type="file" id="fileImage" name="fileImage" value=""/></td>
     </tr>
  </table>
</form>

//Controller action        
  [HttpPost]
  public ActionResult SaveMyImage(int addReplaceImage, HttpPostedFileBase fileImage)
        {
           //save image then return partial view data
	   
        }


这篇关于jQuery弹出窗口中的fileupload控制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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