Hey,
I have drag and drop functionality hooked up in a view which posts back the file to a surface controller.
Problem is once the razor files try to get the CurrentPage on postback the CurrentPage is always null.
Any ideas how can get the CurrentPage? And hard coding the CurrentPage wont work cause there are a couple of razor files which load
This is the razor file:
@inherits UmbracoTemplatePage
@using WebApplication2.umbraco.Surface
@{
Layout = "umbLayout.cshtml";
// If the editor has not explicitly provided the "Page title" property page
// then just show the name of the page otherwise show the provided title
var pageTitle = string.IsNullOrWhiteSpace(CurrentPage.Title)
? CurrentPage.Name
: CurrentPage.Title;
}
<link href="~/css/dropzone.css" rel="stylesheet" />
<div>
@using (Html.BeginUmbracoForm<ConvertSurfaceController>("Convert", FormMethod.Post, new
{
enctype = "multipart/form-data",
id = "uploadDemo",
@class = "dropzone"
}))
{
<div class="fallback row-fluid">
<input name="file" type="file" multiple />
<input type="submit" value="Upload" />
</div>
}
</div>
<script src="~/js/dropzone.js"></script>
<script type="text/javascript">
// "uploadDemo" is the camelized version of the HTML form's ID
Dropzone.options.uploadDemo = {
paramName: "file", // Must match the name of the HttpPostedFileBase argument that the Upload action expects.
maxFileSize: 100 //MB
};
</script>
Here is the controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication2.umbraco.Surface
{
public class ConvertSurfaceController: Umbraco.Web.Mvc.SurfaceController
{
public ActionResult Index()
{
return Content("hello world");
}
[HttpGet]
public ActionResult Convert()
{
return View();
}
[HttpPost]
public ActionResult Convert(HttpPostedFileBase file)
{
//TODO Handle the uploaded file here
return View();
}
}
}
CurrentPage is null on AJAX Postback
Hey, I have drag and drop functionality hooked up in a view which posts back the file to a surface controller.
Problem is once the razor files try to get the CurrentPage on postback the CurrentPage is always null.
Any ideas how can get the CurrentPage? And hard coding the CurrentPage wont work cause there are a couple of razor files which load
This is the razor file:
Here is the controller:
Any help would be great thanks!!
Adrian
Hi Adrian,
I have the same issue just wondering if you'd happened to find a way around it?
There is no CurrentPage available because you're not on a page, your calling back to a SurfaceController.
You could pass in the current Node Id with the AJAX post and then use Umbraco.TypedContent to get the respective content.
http://our.umbraco.org/forum/developers/razor/41775-Getting-IPublishedContent-in-SurfaceController
Thanks,
Matt
is working on a reply...