Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
Razor newbie: Server side notification
posted

Warning I'm new to MVC and web stuff in general, I'm a long time C#/WPF programmer.

What I need to do is upload an excel document from the client, do some parsing of the document, show the parsed values in a form and the save all this to a database.  

So I got the basic MVC form with the upload control and it does upload the file to the server.  My question is how do I notify the controller that the upload is complete so I can parse the file and extract the data?  I'm pretty sure that after I extract the data into my model I can create a simple form to display the results in a form and use the submit button to commit the changes to the database.

I've tried getting client side alerts and that is not working either

UploadWorkbook.cshtml

@using Infragistics.Web.Mvc
@using Infragistics.Web.Mvc
@using OneOfficeWeb.Models
 
@{
    ViewBag.Title = "UploadWorkbook";
}
<script type="text/javascript">
    $(window).load(function () {
        $("#igUpload").bind({
            iguploadonerror: function (e, args) {
                alert(args.errorMessage);
            }
        });
 
 
        $("igUpload1").bind({
            fileUploaded: function(e, args) {
                alert(args.filePath);
            }
        });
    });
        
        
</script>
 
<div class="sampleContents">
    <div class="sample-container">
        <p>Upload workbook</p>
            @using (Html.BeginForm("Upload""UploadWorkbook"FormMethod.Post, new { @encType = "multipart/form-data" }))
            {
                        @(Html.Infragistics().Upload()
                            .ID("igUpload1")
                            .ControlId("uploadControl")
                            .Mode(UploadMode.Single)
                            .AutoStartUpload(true)
                            .AllowedExtensions(new List<string> { "xls""xlsx" })
                            .ProgressUrl(Url.Content("~/IGUploadStatusHandler.ashx"))
                            .ControlId("serverID1")
                            .Render())
            }
 
        <div id="error-message" style="color#FF0000font-weightbold;"></div>
    </div>    
</div>  

Web.config
...
    <httpHandlers>
      <add verb="GET" type="Infragistics.Web.Mvc.UploadStatusHandler"
                      path="IGUploadStatusHandler.ashx" />
    </httpHandlers>
    <httpModules>
      <add name="IGUploadModule" type="Infragistics.Web.Mvc.UploadModule" />
    </httpModules>
  </system.web>

_Layout.cshtml
...
    <link type="text/css" href="@Url.Content("~/Styles/css/themes/infragistics/infragistics.theme.css")" rel="stylesheet" />
    <link type="text/css" href="@Url.Content("~/Styles/css/structure/infragistics.css")" rel="stylesheet" />
 
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")"></script>
   <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui-1.8.11.js")"></script>

Parents
No Data
Reply Children