Reputation: 175
Hi i'm using mvc3 in my application!!!! I'm opening a popup window on click of a link to attach file
on the popup there are 2 buttons 1st button check for some validation like size and also save file on specified path
on the second button i need to save the file name to the database
Till now i can open the popup window like this
@Ajax.ActionLink("Attach File", "attachFile", new { id = item.ID, size=itemFileSize }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup" })
and calling function like this from same view
<script type="text/javascript">
$("#result").dialog({ autoOpen: false,
title: 'title',
width: 800,
height: 275,
modal: true
});
function openPopup() {
$("#result").dialog("open");
} </script>
this is running fine until i press the attach button on this popup and try to return the result to the popup
now this time when i call popup like
return PartialView("attachFile",cwork);
the popup window does not open instead it open as a normal form on window
Here is my code on attachFile view
<form action="/Coursework/attachFile/" method="post" enctype="multipart/form-data">
<td>
<input type="file" name="file" id="file1"/>
</td>
<td> <input type="submit" name="Attach" id="Attach" value="@Resources.prtf_Attach" />
</td>
</form>
....Below this is a submit button
please tell me how can i open the view in same popup window and not as normal page
Upvotes: 1
Views: 2868
Reputation: 26940
You should call popup open function on OnBegin in AjaxOptions Instead of OnSuccess. You should close popup when OnSuccess event fires
Upvotes: 1