我有以下结构:
<div id="wrapper">
<div id="div1">Some content</div>
<div id="div2">Some content</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想"禁用"div2上的tab键,我的意思是当按下Tab键时div2的元素将不会获得焦点.
有没有简单的方法来使用javascript/jquery创建此Tab键控制器?
我正在使用伪造的 HttpContext (最后提供的代码),可能我错过了一些东西,因为我无法访问 TempData 集合(SetFakeControllerContext 方法的第四行)。每次我尝试时都会收到此错误消息:
“controller.TempData”引发了“System.AccessViolationException”类型的异常
调用FakeHttpContext的代码是:
public static void SetFakeControllerContext(this Controller controller)
{
HttpContextBase httpContext = FakeHttpContext(string.Empty);
var context = new ControllerContext(new RequestContext(httpContext, new RouteData()), controller);
controller.ControllerContext = context;
controller.TempData = new TempDataDictionary(); //This is not necessary! It was just a test!!!!
}
Run Code Online (Sandbox Code Playgroud)
有人知道我做错了什么吗?
public static HttpContextBase FakeHttpContext(string username){
var context = new Mock<HttpContextBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
var session = new Mock<HttpSessionStateBase>();
var server = new Mock<HttpServerUtilityBase>();
var user = new …Run Code Online (Sandbox Code Playgroud) 我有一个包含供应商信息的数据库:名称和地址(地址,城市,邮编和国家/地区).我需要搜索这个数据库并返回一些供应商.在搜索框中,用户可以输入任何内容:供应商的名称,地址的一部分,城市,邮政编码......如果我找不到任何结果,我需要像谷歌一样实施"你的意思是"向用户提供建议的功能.
我想过使用Solr/Lucene来做这件事.我已经安装了Solr,使用CSV文件导出了我需要的信息,并根据此文件创建了索引.现在,我可以使用solr.SpellCheckComponent从Solr字段获取建议.问题是我的建议是基于一个领域,需要它从地址,城市,邮编,国家和名称字段中获取信息.
在solr配置文件中我有这样的东西:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpell</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">name</str>
<str name="spellcheckIndexDir">spellchecker</str>
</lst>
</searchComponent>
<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count>1</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
Run Code Online (Sandbox Code Playgroud)
我可以运行如下查询:
http://localhost:8983/solr/spell?q=some_company_name&spellcheck=true&spellcheck.collate=true&spellcheck.build=true
Run Code Online (Sandbox Code Playgroud)
有谁知道如何更改我的配置文件,以获得多个字段的建议?
谢谢!!!
asp.net-mvc ×1
html ×1
httpcontext ×1
javascript ×1
jquery ×1
lucene ×1
mocking ×1
moq ×1
solr ×1
tempdata ×1