我们接管了之前设计的网站.我们将从头开始重写所有CSS.目前的网站项目有几个'class ="stuff foo"'和其他很多类.
在Sublime Text 2中有没有办法删除所有类元素中的所有项目?
例:
<div id="BasicLogin" class="login 50per wide homepage">
Run Code Online (Sandbox Code Playgroud)
清除:
<div id="BasicLogin" class=""> OR
<div id="BasicLogin">
Run Code Online (Sandbox Code Playgroud) 我们正在使用Blueimp Jquery文件上传.
我们如何添加按钮来触发上传?
现在,只要用户选择文件,就会立即上传.我们希望用户选择文件,然后单击UPLOAD NOW按钮.
我已经更改了JS文件,将autoUplaod打开为false,但可以弄清楚如何使OnClick工作.
<script>
$(function () {
$('#fileupload').fileupload({
dataType: 'json',
done: function (e, data) {
$.each(data.result, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 如何将JavaScript对象传递给ASP.NET Handler并解析值?
我创建了一个复杂类型对象,如:
function AccountObjCreate() {
var AccountsView = {};
AccountsView.Username = null;
AccountsView.Email = null;
AccountsView.Password = null;
return AccountsView;
}
Run Code Online (Sandbox Code Playgroud)
并填写该对象,如:
var aView = AccountObjCreate();
aView.Username = $('#tbUserName').val().trim();
aView.Email = $('#tbEmail').val().trim().toLowerCase();
aView.Password = $('#tbPassword').val().trim();
Run Code Online (Sandbox Code Playgroud)
然后我打电话给:
$.post("/Handlers/AccountHandler.ashx", { obj: aView },
function (results) {
if (results.isSuccess) {
alert(results.msg);
} else {
alert(results.msg);
}
}, "json");
Run Code Online (Sandbox Code Playgroud)
当我在控制台中查看它时,我将aView中的所有数据视为json.
我的ASP.NET处理程序页面是
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
string obj = context.Request["obj"];
Run Code Online (Sandbox Code Playgroud)
但是obj是NULL.
我跑步时遇到错误
string quote = Page.RouteData.Values["quote"].ToString() ?? string.Empty;
Run Code Online (Sandbox Code Playgroud)
错误:对象引用未设置为对象的实例.
我知道ToString导致错误,因为Page.RouteData.Values ["quote"]为空/ null.
在执行ToString之前,如何检查Page.RouteData.Values ["quote"]是否有值?
我想让JQuery定位以下项目并使用动态GUID(ruID)更改TEXT:
<span class="btn btn-mini emailIntive" data-id="a9c83938-0c2e-4433-a0f0-9aafc1aae541"> Invite </span>
Run Code Online (Sandbox Code Playgroud)
我使用的JQuery代码是:
$('.emailIntive' + data('id')=== ruID).text("SENT");
Run Code Online (Sandbox Code Playgroud)
我收到'数据未定义'错误.
如何使用JQuery定位CLASS NAME +特定的data-id?
我有一个类别表,我将结果传递到一个方法中:
view.Category = ctx.Categories.Select(CategoryMap.IndustryPage).ToList();
Run Code Online (Sandbox Code Playgroud)
效果完美。IndustryPage()现在我想向函数传递一个额外的项目
public static CategoryIndustryView IndustryPage(DAL.Category data, int indID)
Run Code Online (Sandbox Code Playgroud)
我厌倦了以下内容,但我知道语法很差劲:
view.Category = ctx.Categories.Select(CategoryMap.IndustryPage(this,industryID)).ToList();
Run Code Online (Sandbox Code Playgroud)
如何将 传递indID到 Select 中以便可以在IndustryPage()函数中访问它?
更新/工作
使用下面的@MarcinJuraszek,我能够让它工作:
var catData = ctx.Categories.ToList();
view.Category = catData.Select(x => CategoryMap.IndustryPage(x, industryID)).ToList();
Run Code Online (Sandbox Code Playgroud)
我首先将记录检索到 catData 然后 SELECT .. 工作了!
出于某种原因,这看起来不正确.有没有更好的方法来编写/折射这个?
if (!(auth.DoesAuthMatch && auth.DoesEmailMatch))
{
statusText = "Access Denied";
}
Run Code Online (Sandbox Code Playgroud)
我想我有一个'周一的案例!......'
我有以下HTML代码
<label class="fileinput-button" id="fileUpload-label">
<span class="btn btn-add" id="fileUpload-span">Add a file..</span>
<div id="fileinput-outer">
<input type="file" name="files[]" id="fileUpload">
</div>
</label>
Run Code Online (Sandbox Code Playgroud)
然后我使用Jquery获取Input type = File的文件列表
$('#fileUpload').live('change', function () {
$.map($('#fileUpload').get(0).files, function (file) {
$('#fileList')
.append(CreateFileList(file.name, true));
});
});
Run Code Online (Sandbox Code Playgroud)
这在Chrome和Firefox中运行良好,但在IE中错误是
Unable to get value of the property 'length': object is null or undefined
Run Code Online (Sandbox Code Playgroud)
所以我开始麻烦并且有这个代码
var arrFiles[];
arrFiles = $('#fileUpload').get(0).files;
if(arrFiles.length === 0) {
alert('empty');
} else {
alert('has value');
}
Run Code Online (Sandbox Code Playgroud)
Chrome和Firefox - 代码和警报按预期工作,但IE仍然会引发错误
Unable to get value of the property 'length': object is null …Run Code Online (Sandbox Code Playgroud) 我试图避免两次调用数据库.我需要检查记录是否存在,如果是,那么用数据填充我的视图.我有以下代码:
if (Presenters.PayeePresenter.GetByID(id) != null)
{
view = BLL.Presenters.PayeePresenter.GetByID(id);
msg.Success = true;
msg.Text = "Record Found";
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能对数据库进行最少量的调用?
我需要从POST中获取所有FIELD和VALUES.
我有以下只返回FIELD但没有值.
NameValueCollection authForm = Request.Form;
String[] a = authForm.AllKeys;
for (i = 0; i < a.Length; i++)
{
frm += ("Form: " + a[i] + " : " + "<br>");
}
Response.Write(frm);
Run Code Online (Sandbox Code Playgroud)
我可以添加这个frm字符串来显示VALUES吗?
更新:
我用的是初始代码
NameValueCollection authForm = Request.Form;
foreach (string key in authForm.AllKeys)
{
frm += ("Key: " + key + ", Value: " + authForm[key] + "<br/>");
}
Run Code Online (Sandbox Code Playgroud)
这很棒.我将尝试下面的新变体.
c# ×6
asp.net ×3
jquery ×3
arrays ×1
blueimp ×1
collections ×1
css ×1
file-upload ×1
guid ×1
httphandler ×1
javascript ×1
json ×1
refactoring ×1
regex ×1
routes ×1
sublimetext2 ×1