Jquery 你甚至可以在它准备好的时候发出警报。啊,有趣的是,你的说法是,将所有数据作为json对象放在一个表单字段中,然后提交它,并使用此自定义模型绑定器将其转换为我的模型。。。当然我正在努力实现这个。。。我的项目是在vb.net中。我不明白:过滤器集(obj);'
Jquery 你甚至可以在它准备好的时候发出警报。啊,有趣的是,你的说法是,将所有数据作为json对象放在一个表单字段中,然后提交它,并使用此自定义模型绑定器将其转换为我的模型。。。当然我正在努力实现这个。。。我的项目是在vb.net中。我不明白:过滤器集(obj);',jquery,asp.net-mvc,performance,internet-explorer,download,Jquery,Asp.net Mvc,Performance,Internet Explorer,Download,你甚至可以在它准备好的时候发出警报。啊,有趣的是,你的说法是,将所有数据作为json对象放在一个表单字段中,然后提交它,并使用此自定义模型绑定器将其转换为我的模型。。。当然我正在努力实现这个。。。我的项目是在vb.net中。我不明白:过滤器集(obj);'什么是filterset?好的,所以我没有使用这个,但它引导我找到了我的最终解决方案,它将整数列表作为一个字符串字段发送,并且在模型上有一个只读属性,将它们转换为(整数的)列表,谢谢你的想法!对不起,我的代码有歧义。FilterSet对象是我创
你甚至可以在它准备好的时候发出警报。啊,有趣的是,你的说法是,将所有数据作为json对象放在一个表单字段中,然后提交它,并使用此自定义模型绑定器将其转换为我的模型。。。当然我正在努力实现这个。。。我的项目是在vb.net中。我不明白:过滤器集(obj);'什么是filterset?好的,所以我没有使用这个,但它引导我找到了我的最终解决方案,它将整数列表作为一个字符串字段发送,并且在模型上有一个只读属性,将它们转换为(整数的)列表,谢谢你的想法!对不起,我的代码有歧义。FilterSet对象是我创建的自定义对象。它基本上是传递回来的JSON对象的静态类型版本。我很高兴能帮你找到解决问题的办法!哦,好吧,这只是把obj变成你喜欢的类型。那很酷。
jQuery.download = function (url, data, method, loadingHolderDivId) {
if (url && typeof data == 'object') {
//for this version, data needs to be a json object.
//loop through the data object..
$('#' + loadingHolderDivId).html($('#LoadingScreen').html());
var theForm = $('<form></form>').attr('action', url).attr('method', method).attr('id', 'jqueryDownloadForm').attr('target', 'iframeX');
$.each(data, function (propertyName, propertyVal) {
if (propertyVal != null) {
if (typeof propertyVal == 'object') {
//HANDLE ARRAYS!
for (var i = 0, len = propertyVal.length; i < len; ++i) {
theForm.append($("<input />").attr('type', 'hidden').attr('id', propertyName + i.toString).attr('name', propertyName).val(propertyVal[i]));
}
}
else {
theForm.append($("<input />").attr('type', 'hidden').attr('id', propertyName).attr('name', propertyName).val(propertyVal));
}
}
});
var iframeX;
var downloadInterval;
// remove old iframe if has
$("#iframeX").remove();
// create new iframe
iframeX = $('<iframe src="javascript:false;" name="iframeX" id="iframeX"></iframe>').appendTo('body').hide();
if ($.browser.msie) {
downloadInterval = setInterval(function () {
// if loading then readyState is “loading” else readyState is “interactive”
if (iframeX && iframeX[0].readyState !== "loading") {
$('#' + loadingHolderDivId).empty();
clearInterval(downloadInterval);
}
}, 23);
}
else {
iframeX.load(function () {
$('#' + loadingHolderDivId).empty();
});
}
theForm.appendTo('body').trigger('submit').remove();
return false;
}
else {
//they didn't fill in the params. do nothing
}
};
Function ExportUsers(ByVal model As ExportUsersPostModel) As ActionResult
<Serializable()> _
Public Class ExportUsersPostModel
Public Property FilterUserIds As IList(Of Integer) = New List(Of Integer)
Public Property FilterColumnIds As IList(Of Integer) = New List(Of Integer)
public property ShowThis as boolean
public property OtherStuff as string = string.empty
Public Property FormatId As Integer
End Class
internal class FilterBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
if (controllerContext == null)
throw new ArgumentNullException("controllerContext");
if (bindingContext == null)
throw new ArgumentNullException("bindingContext");
if ((controllerContext.HttpContext.Request.Form.Count > 1 || (controllerContext.HttpContext.Request.Form.Count == 1 && !string.IsNullOrWhiteSpace(controllerContext.HttpContext.Request.Form.AllKeys[0]))) || (controllerContext.HttpContext.Request.QueryString.Count > 1 || (controllerContext.HttpContext.Request.QueryString.Count == 1 && !string.IsNullOrWhiteSpace(controllerContext.HttpContext.Request.QueryString.AllKeys[0]))))
{
ValueProviderResult val = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
string value = val == null || string.IsNullOrEmpty(val.AttemptedValue) ? string.Empty : val.AttemptedValue;
if (string.IsNullOrEmpty(value)) return null;
dynamic obj = JObject.Parse(value);
return new FilterSet(obj);
}
else
return null;
}
}