This is a migrated thread and some comments may be shown as answers.

[Solved] [!Rank Noob question!] upload file then call action with filename

1 Answer 20 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
A
Top achievements
Rank 1
A asked on 15 Aug 2011, 04:20 PM
Hi,
First of all, sorry, it's been a while since I developed web, and I missed ajax (let alone jQuery) completely...
So, I would like to do the following:
User uploads a .csv, .txt or .zip file. The user should have a button - just selecting the file shouldn't trigger the upload. User uploads, and upon successful completion, a button/link appears enabling the user to submit the just uploaded filename for processing.
So what is my problem? The last bit. I managed to get an Ajax.ActionLink to appear on successful completion, though I would rather a button. The next part though, I am a little lost - I have a partial view that returns some text (the result of processing) but the link seems to want to take the whole page with it, and it ends up just being a full get on the partial view.
Is there a better way to do this? I've done quite a bit (years) of asp.net but I'm ashamed to say this is the first proper ajax page I've ever coded! So some gentle code examples would be most appreciated!
Thanks heaps
Anton

1 Answer, 1 is accepted

Sort by
0
A
Top achievements
Rank 1
answered on 15 Aug 2011, 08:40 PM
Including the javascript libraries that enables interpreting the data-* tags is always a good start for this sort of thing!!! Argh, so much wasted time! I won't be doing that again!
Including 
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
Meant that my action link is now working, and excepting passing the filename to my partial view method, I now have what I want happening.

Quick supplementary question - my project started out it's life as a stock "telerik razor c# project", where is the best place to put this include? Why isn't it included by default? I put it after 
@(Html.Telerik().ScriptRegistrar().Globalization(true).DefaultGroup(group => group.Combined(true).Compress(true)))
in _Layout.cshtml - is this the right place to put it? 
Thanks
Anton
Tags
Upload
Asked by
A
Top achievements
Rank 1
Answers by
A
Top achievements
Rank 1
Share this question
or