我遇到问题,jQuery没有识别我页面上的元素,并抛出一个错误,说我试图选择的元素是null.
我们将内容插入到以下包装器中,该包装器由客户端提供:
http://www.ft.com/global/mm0802/ag/wrapper
包装器包含以下字符串:
<!-- ftplchol id="contentFixed" version="1.0" -->
我们用我们的内容替换然后呈现页面.
这是我们内容的一个示例:(我遇到的问题在下面描述)
<script src="/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('.ActionControl a').live("click", function () {
$.get($(this).attr("href"), {}, function (result) {
// do stuff with result
});
}, "html");
return false;
});
});
</script>
<div class="ActionControl">
<span>Fund Directory</span>
<span>
<a href="/funddirectory/DirectoryResult">A</a>
</span>
<span>
<a href="/funddirectory/DirectoryResult/B">B</a>
</span>
<span>
<a href="/funddirectory/DirectoryResult/C">C</a>
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
当我在包装器的上下文之外运行我的东西时,一切都很好.我的代码表现如预期.但是当我运行整个页面并将内容插入到包装器中时,以下行会引发错误:
$('.ActionControl a').live("click", function () {
说这$('.ActionControl a')是空的.特别:Microsoft JScript runtime error: 'null' is null or not an …
我有
public class FundController
{
private Site _site;
public ViewResult Fund()
{
}
}
Run Code Online (Sandbox Code Playgroud)
我想在此基金方法中添加一个动作过滤器:
public class FundController
{
private Site _site;
[MyFilter]
public ViewResult Fund()
{
}
}
Run Code Online (Sandbox Code Playgroud)
但是Action Filter需要访问权限_site.这可能吗?如果是这样,怎么样?
我问,因为我的好友早先发布了一个关于如何在测试HtmlHelper时解决图像路径问题的问题?我们办公室的一些人谈论了如何解决这个问题.
其中一个人建议他不会遇到这个问题(测试崩溃,因为它依赖于IIS中的功能)如果他从CSS引用图像.
他的观点很有道理,但它让我们失望,因为我们一直在用图像来引用图像<img/>.我们一直都做错了吗?我们都不是这方面的专家,所以我认为值得投入社区.什么是参考图像的最佳方式?
我们正在开发一个新系统来取代现有系统.
新系统是ASP.NET MVC,因此我们正常地定义到控制器和操作的路由.
旧系统作为传统的ASP.NET,因此URL由许多.aspx页面组成.
我们想要设置重定向,以便当用户尝试访问时/Homepage.aspx(许多用户会将其加入书签),他们将被重定向到新系统的默认路由,这只是/
我这样做的最佳方式是什么?
编辑: @Chance建议在下面我指定路线:
routes.MapRoute("Homepage", "Homepage.aspx", new { controller = "controller", action = "homepage" });
这有效,但我想做一个重定向,因为我不想Homepage.aspx在地址栏中.还有什么我可以做的吗?
我正在尝试根据 RegEx 验证电话号码。
我得到了这个答案:
它定义了用于验证以下电话号码的表达式:+44 (0) 1234 123456
我已经将它从 JS 移植到 C#,成为
var regexPhone = new Regex(@"^(?!([^-]*-){5})(\+\d+)?\s*(\(\d+\))?[- \d]+$");
这是有效的,但验证器也适用于允许为空的电话号码字段,例如传真(不是每个人都拥有那些老式设备之一)。
如何更改此设置以允许空白,以及针对上述数字进行验证?
编辑:下面的答案适用于上面的数字,但它失败了:+ 44 (0)20 1234 1234。还有什么我可以添加的吗?
我对这个NHibernate查询的结果感到有点困惑:
var result = (List<RatingsLipper>)_session.CreateCriteria<RatingsLipper>()
.Add<RatingsLipper>(xx => xx.ShareClassId == shareClassId)
.List<RatingsLipper>();
Run Code Online (Sandbox Code Playgroud)
哪里RatingsLipper有以下映射:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="FTMS.Domain"
namespace="FTMS.Domain.Entities">
<class mutable="false" name="RatingsLipper" table="LipperRating" schema="offline">
<id name="Id" column="LipperRating_LipperId">
<generator class="native"></generator>
</id>
<property name="ShareClassId" column="LipperRating_ShareClassId" />
<property name="RatingDate" column="LipperRating_RatingDate" />
<property name="TimePeriod" column="LipperRating_RatingTimePeriodYears" />
<property name="TotalReturn" column="LipperRating_TotalReturn" />
<property name="ConsistentReturn" column="LipperRating_ConsistentReturn" />
<property name="Preservation" column="LipperRating_Preservation" />
<property name="Expense" column="LipperRating_Expense" />
</class>
</hibernate-mapping>
Run Code Online (Sandbox Code Playgroud)
该查询生成以下SQL:
SELECT this_.LipperRating_LipperId ,
this_.LipperRating_ShareClassId ,
this_.LipperRating_RatingDate ,
this_.LipperRating_RatingTimePeriodYears,
this_.LipperRating_TotalReturn ,
this_.LipperRating_ConsistentReturn ,
this_.LipperRating_Preservation ,
this_.LipperRating_Expense
FROM offline.LipperRating this_
WHERE …Run Code Online (Sandbox Code Playgroud) 我知道在Update 3中我们可以指定自定义声音.但除了默认的铃声之外,是否可以在Update 3之前指定任何不同的声音?如果是这样,怎么样?
以下是我发送给手机的xml有效负载
<?xml version="1.0" encoding="Windows-1252"?>
<wp:Notification xmlns:wp="WPNotification">
<wp:Toast>
<wp:Text1>WEATHER ALERT</wp:Text1>
<wp:Text2>asdfasdf</wp:Text2>
<wp:Param>/Page2.xaml?NavigatedFrom=Toast Notification</wp:Param>
</wp:Toast>
<wp:audio src="ms-winsoundevent:Notification.IM" loop="true" />
</wp:Notification>
Run Code Online (Sandbox Code Playgroud)
但不管我在线上指定了什么声音
<wp:audio src="ms-winsoundevent:Notification.IM" loop="true" />
Run Code Online (Sandbox Code Playgroud)
要么
<wp:audio src="ms-winsoundevent:Notification.Looping.Alarm7" loop="true" />
Run Code Online (Sandbox Code Playgroud)
它总是播放相同的声音.
我做错了什么还是不可能?
我正在谷歌搜索测试推送通知到Windows Phone 8.1的东西,或者概述制作一个或预先构建的测试应用程序所需的内容.
我发现的大部分结果都与Windows Phone 8和Windows Phone Silverlight 8.1有关.
由于这仅用于测试,因此未经身份验证的服务就足够了.
我想要实现的是将以下方法转换为更通用的方法:
private Task<TestResult> SpecificServiceWarmUp(string serviceEndPoint)
{
return Task<TestResult>.Factory.StartNew(() =>
{
using (var service = new MySpecificClient(serviceEndPoint))
{
// do some stuff with specific client
}
});
}
Run Code Online (Sandbox Code Playgroud)
更通用的版本看起来像:
private Task<TestResult> GenericServiceWarmUp<TService>(string serviceEndPoint)
{
return Task<TestResult>.Factory.StartNew(() =>
{
using (/* instance of TService */)
{
// do some stuff with generic client
}
});
}
Run Code Online (Sandbox Code Playgroud)
我不知道的是如何告诉using块Activator用于创建泛型类型的实例.这可能吗?如果是这样,我该怎么做?
我目前正在获取表单中存在的所有Select元素,其中包含以下内容:
$("form").submit(function(event)
{
// gather data
var data = GetSelectData($("form select"));
// do submit
$.post($(this).attr("action"), data, ..etc)
});
Run Code Online (Sandbox Code Playgroud)
而不是传入$("form select"),有没有办法可以说出类似的东西
$(this).children('select') // this doesn't work, btw
Run Code Online (Sandbox Code Playgroud)
获取提交事件正在执行的表单上下文中存在的所有选择元素?
这将允许我将我的代码减少到以下,将所有功能转移到一个通用功能:
$("form").submit(function(event)
{
GatherDataAndSubmit($(this));
});
function GatherDataAndSubmit(obj)
{
var data = GetSelectData(obj.children('select'));
$.post(obj.attr("action"), data, ..etc)
}
Run Code Online (Sandbox Code Playgroud)
谢谢
戴夫