i want to partialrender some control for example.
her my code:
<script type="text/javascript">
$("#datetime").datepicker({ dateFormat: 'dd.mm.yy', onSelect: function (dateText, inst) {
$.ajax({
type: 'POST',
data:
{
datetime: dateText
},
url: '<%= VirtualPathUtility.ToAbsolute("~/ExcelToHtml") %>',
async: true,
success: function (response) { $('#report').html(response) }
});
}
});
</script>
<div id="report">
</div>
here server code:
public PartialViewResult ExcelToHtml(DateTime datetime) {
ViewData["datetime"] = datetime;
return PartialView("ExcelToHtml");
}
now, i want to see my date, in div(id=report), but i dont see it.
thats just example, can not understand where am i wrong?
and the control ExcelToHtml.ascx:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<% ViewData["datetime"].ToString(); %>
Firstly, I just wanted to point out that you don’t need to specify the view name when it is the same as the action name…
Secondly, to check your mechanism works, just put a placeholder on the partial view with nothing else…
I think that it is likely that you will see “Hello World” loaded into the div.
This leads onto the next point – can you share the code for the view – as I think the error is most likely to be in there.