小编Sur*_*thy的帖子

Javascript无法在Partial View中使用

此问题类似于ASP.NET MVC中部分视图中的Execute Javascript中描述的问题

index.cshtml中的下面一段代码工作得很好......


<label for="locationOfSearch"> in :</label> @Html.TextBox("locationOfSearch")

<input type="submit" value="Search"  style="background-color:Green"/>

@section JavaScript {
    <script type="text/javascript">
        $(document).ready(function () {


            $("#locationOfSearch").autocomplete({
                source: '@Url.Action("AutocompleteAsyncLocations")'
            })



        });
    </script>
}
Run Code Online (Sandbox Code Playgroud)

但是,当我将上述代码和相应的脚本文件复制并粘贴到另一个视图,然后在index.cshtml中,如果我调用Html.Partial(新视图名称),则自动完成功能无效...

请告诉我如何解决它而不需要太多修改......

asp.net asp.net-mvc-partialview asp.net-mvc-3

13
推荐指数
1
解决办法
4万
查看次数

如何解析Google Distance Matrix API中的JSON输出?

http://www.giantflyingsaucer.com/blog/?p=2227&cpage=1提供了ASP.NET MVC和Google API集成的好方法.

在URL缩短的情况下,响应结构很简单:

private class GoogleShortenedURLResponse
{
    public string id { get; set; }
    public string kind { get; set; }
    public string longUrl { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我对Google Distance Matrix API采用了相同的方法......但我不知道如何定义响应结构......你有什么想法吗?

google-api asp.net-mvc-3

1
推荐指数
1
解决办法
3431
查看次数