我正在使用谷歌地方API与地理编码.我的地址组件类型有问题.
我想获取有关用户在此格式中输入自动填充的地址的信息:
街道号/街道/城市/省/国家/地区.
如果用户自动完成了"Street 12,SomeCity,SomeProvince,SomeCountry",我想要提醒所有这些信息.但是当用户只输入"someProvince,SomeCountry"时,我想只有省和国家地址类型.
这是我的代码:
google.maps.event.addListener(autocomplete, 'place_changed', function () {
var place = autocomplete.getPlace();
alert('0: ' + place.address_components[0].long_name);
alert('1: ' + place.address_components[1].long_name);
alert('2: ' + place.address_components[2].long_name);
alert('3: ' + place.address_components[3].long_name);
alert('4: ' + place.address_components[4].long_name);
alert('5: ' + place.address_components[5].long_name);
alert('6: ' + place.address_components[6].long_name);
alert('7: ' + place.address_components[7].long_name);
)};
Run Code Online (Sandbox Code Playgroud)
问题是当用户自动完成完整地址时,它会正确显示所有这些警报.但是,当自动完成仅部分信息 - 仅限国家/地区 - 它将显示7次输入国家/地区的信息.
http://gmaps-samples-v3.googlecode.com/svn/trunk/places/autocomplete-addressform.html
我想要的是,当没有给出街道和城市时,它会显示警报("街道为空"等).怎么做?
我有List<string>一些话.我想获得所有元素,女巫包含这个模式中的字母:
a00b0c000d- 0是随机字符,a,b,c,d- 字符串中不断的字符.
我怎样才能做到这一点?我只能用Regex做到这一点吗?没有任何其他解决方案?
我有个问题.当我尝试将用户从MVC操作重定向到非http URL时,它返回:
对象转移到了这里.
完整回复(来自Fiddler):
HTTP/1.1 301 Moved Permanently
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: myGame-app://test.somespecificdata
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcUGlvdHJcRGVza3RvcFxUYWtlc0NhcmVcVGFrZXNDYXJlXERvY3RvcnNcRWRvY3RvclxDb25zdWx0YXRpb25cMTkx?=
X-Powered-By: ASP.NET
Date: Thu, 18 Jun 2015 18:19:35 GMT
Content-Length: 457
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="myGame-app%3a%2f%2ftestprotocol.somespecificdata">here</a>.</h2>
<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
{"appName":"Firefox"}
</script>
<script type="text/javascript" src="http://localhost:53098/4c9c75263d91451fa797f9041e4bd0f3/browserLink" async="async"></script>
<!-- End Browser Link -->
</body></html>
Run Code Online (Sandbox Code Playgroud)
我的动作(伪代码):
[HttpGet]
public ActionResult Consultation(int id)
{
//.. specific business logic
if(IsMobile()){
return RedirectPermanent("myGame-app://test.somespecificdata");
}
else{
return View("AboutGame", …Run Code Online (Sandbox Code Playgroud) 如何使用lambda和linq按范围获取元素?
例如:
我有一个包含54个元素的表.我只是想从1-10或10-20或20-30之类的元素中获取元素 - 通常是通过一些数值范围.
我怎样才能做到这一点?
我有个问题.在主服务器和localhost上是exacly相同的文件.
但是在localhost中我有我母语的消息,比如
Pole Email jest wymagane.
在主服务器上我有:
The Email field is required.
正如我所说,文件非常相似.怎么解决?
如何按具体方式获取所有节点Document Type?
例如,我想在所有节点后面使用代码Document Type: s3Article.我怎样才能做到这一点?
新信息:
IEnumerable<Node> nodes = uQuery.GetNodesByType("s3Article").Where(x => x.NiceUrl.Contains("en"));
lvArticles.DataSource = nodes;
lvArticles.DataBind();
Run Code Online (Sandbox Code Playgroud)
这是我的代码.我不得不使用Where(x => x.NiceUrl.Contains("en")),因为我有2个语言版本 - 没有Where我收到所有带doctype的目录中的节点s3Article,但我想只从一个语言版本获得.
问题在这里:
<a href='<%# umbraco.library.NiceUrl(Tools.NumericTools.tryParseInt( Eval("id"))) %>'><%# Eval("title")%></a>
<%# Tools.TextTools.makeIMGHTML("../.."+ Eval("img").ToString(),"180") %>
<%# umbraco.library.StripHtml(Limit(Eval("Article"), 1000))%>
<%# Eval("author")%>
Run Code Online (Sandbox Code Playgroud)
System.Web.HttpException:DataBinding:'umbraco.presentation.nodeFactory.Node'不包含名为'title'的属性.
标题,img,文章,作者也会出现同样的问题.只有ID很好用.怎么解决?
我的代码存在奇怪的问题 - 请看一下:
@Url.Action("IdeaVote","Ideas", new { IdeaID = "1", vote = "For" })
Run Code Online (Sandbox Code Playgroud)
方法中的值(从调试器获取):
IdeaID = 1,投票= null
现在有一些神奇的提示(反向投票和IdeaID).
@Url.Action("IdeaVote","Ideas", new { vote = "For", IdeaID = "1" })
Run Code Online (Sandbox Code Playgroud)
方法中的值(从调试器获取):
vote = for,IdeaID = null
方法IdeaVote(参数)
public int IdeaVote(string vote, string IdeaID)
Run Code Online (Sandbox Code Playgroud)
我的问题是 - 为什么第二个参数总是为空?为什么会出现这种情况?
问候
编辑:
我的url.action的jQuery方法
$.get("@Url.Action("IdeaVote","Ideas", new { IdeaID = "1", vote = "For" })",function(data)
{
if (data == 1) {
$("#imageVoteAgainst").css("border-width", 0);
$("#imageVoteFor").css("border-width", 1);
}
});
Run Code Online (Sandbox Code Playgroud) 我有个问题.如何在"<"和">"(HTML标签)之间更改文本到大写字母?部分代码:
string a= @"<html><b>hello world!</b>
<table>test</table></html>";
a = Regex.Replace(a, @"<(.|\n)*?>", String.Empty);
Run Code Online (Sandbox Code Playgroud)
现在,输出是:
hello world!
test
Run Code Online (Sandbox Code Playgroud)
我希望:
<HTML><B>hello world!</B>
<TABLE>test</TABLE></HTML>
Run Code Online (Sandbox Code Playgroud)
我知道String.Empty删除<>之间的代码,但如何将此文本更改为大写字母?请给我一些建议,怎么做.
问候!
我有一个简单的问题.为什么在下面的代码中,这部分HttpPostedFileBase file- 是空的?当然ArticleModel model不是空的,只是file.
开始我的控制器动作:
public ActionResult Add(ArticleModel model, HttpPostedFileBase file)
...
Run Code Online (Sandbox Code Playgroud)
我的表格:
<section id="">
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary()
@ViewBag.Status
<fieldset>
<legend>Add</legend>
<ol>
<li>
@Html.LabelFor(m => m.title)
@Html.TextBoxFor(m => m.title)
</li>
<li>
@Html.LabelFor(m => m.Categories)
@Html.DropDownListFor(m=> m.categoryID, Model.Categories, "- lorem -", new { @class="dropdownlist" })
</li>
<li>
@Html.LabelFor(m => m.connectedArticlesID)
@Html.TextBoxFor(m => m.connectedArticlesID)
</li>
<li>
<input type="file" name="file" id="file" />
</li>
<li>
@Html.LabelFor(m => m.introduction)
@Html.EditorFor(m => m.introduction)
</li>
<li>
@Html.LabelFor(m => m.content) …Run Code Online (Sandbox Code Playgroud) 我有个问题.这部分代码在~1min System.OutOfMemoryException错误后返回.但我无法找到什么可能导致这个错误.如果有人告诉我这个问题的原因是什么,以及如何解决,我会很高兴.
我的部分主题:
public void Run(object client)
{
TextBox tbServerResult = (client as Client).Controls.Find("tbServerResult", true).SingleOrDefault() as TextBox;
Client tt = new Client();
for (int i = 0; i < 1; i--)
{
Thread.Sleep(10000);
string result = tt.SendGet("xyz" + tt.getToken() + "");
tbServerResult.AppendText(result);
}
}
Run Code Online (Sandbox Code Playgroud)
SendGet方法:
public string SendGet(string url)
{
string webpageContent = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
using (HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
{
webpageContent = reader.ReadToEnd();
}
//tbServerResult.AppendText("\r\n" + …Run Code Online (Sandbox Code Playgroud) 我的问题是:如何发送超过1个@model IEnumerable<MvcMovie.Models.Movie>?
例如 - 我想从Controler发送到View:db.Movies.ToList()和db.Letters.ToList().怎么发送?
以及如何在我的视图中分离:IEnumerable与电影和IEnumerable与字母?
是否有可能从.Where声明中只获得一列?例如 - ID.
List<testB> test = db.testB.Where(x => x.UserID == userId).ToList();
Run Code Online (Sandbox Code Playgroud)
在这里,我得到了所有的邀请testB.
我只是想要回List<int>用testB.ID代替List<testB>.我怎样才能做到这一点?
c# ×7
.net ×5
asp.net-mvc ×5
asp.net ×2
linq ×2
google-api ×1
google-maps ×1
lambda ×1
localization ×1
php ×1
umbraco ×1