小编Mil*_*lar的帖子

Jquery从下拉列表中获取SelectedText

我试图使用Jquery从下拉列表中获取所选文本.

<div>
    @Html.DropDownList("SelectedCountryId", Model.CountryList, "(Select one Country)")
</div>
Run Code Online (Sandbox Code Playgroud)

下面给出的是我正在使用的Jquery.但这不起作用.我试过了

var selectedText1 = $("#SelectedCountryId").val($(this).find(":selected").text()); 
Run Code Online (Sandbox Code Playgroud)

并返回[对象对象].但是如何阅读所选文字?

接下来我试过了

var selectedText2 = $("#SelectedCountryId:selected").text();
Run Code Online (Sandbox Code Playgroud)

然后它返回空.

我也试过了

var selectedText2 = $("#SelectedCountryId option:selected").text();
Run Code Online (Sandbox Code Playgroud)

这也是空的.

我可以使用返回selectedID

var selectedID = $("#SelectedCountryId").val();
Run Code Online (Sandbox Code Playgroud)

但为什么不选择文字呢?

我的Jquery在这里有什么问题吗?请帮忙

<script src="@Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#SelectedCountryId").change(function () {

                var selectedText1 = $("#SelectedCountryId").val($(this).find(":selected").text());
                var selectedText2 = $("#SelectedCountryId:selected").text();
                alert("You selected :" + selectedText1 + selectedText2 );


            });
Run Code Online (Sandbox Code Playgroud)

这是我下面的下拉列表的HTML

<select id="SelectedCountryId" name="SelectedCountryId"><option value="">(Select one Country)</option>
<option value="19">USA</option>
<option value="10">Germany</option>
<option value="12">Australia</option> </select>
Run Code Online (Sandbox Code Playgroud)

jquery asp.net-mvc-3

26
推荐指数
2
解决办法
12万
查看次数

无法加载文件或程序集"Microsoft.TeamFoundation.WorkItemTracking.Client.Cache"或其依赖项之一

我正在开发一个与TFS交互的Web应用程序.当我将我的应用程序上传到Windows azure云时,我收到此错误消息.

感谢您提供解决此问题的意见.

粘贴在下面是我收到的错误消息

Server Error in '/' Application.
--------------------------------------------------------------------------------


Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. …
Run Code Online (Sandbox Code Playgroud)

asp.net azure tfs2010

19
推荐指数
4
解决办法
3万
查看次数

扩展MVC3 razor Html.LabelFor以添加css类

我想在EditorTemplate上为Html.LabelFor添加一个css类

 @Html.LabelFor(model => model.Name, new { @class = "myLabel" })
Run Code Online (Sandbox Code Playgroud)

我的期望例如:label应该拿起css类.

为此我尝试使用以下代码扩展Label,但我的标签没有出现.我在这做错了什么?

 public static class LabelExtensions
    {
        public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object htmlAttributes)
        {
            return html.LabelFor(expression, null, htmlAttributes);
        }

        public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string labelText, object htmlAttributes)
        {
            return html.LabelHelper(
                ModelMetadata.FromLambdaExpression(expression, html.ViewData),
                ExpressionHelper.GetExpressionText(expression),
                HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes),
                labelText);
        }

        private static MvcHtmlString LabelHelper(this HtmlHelper html, ModelMetadata metadata, string htmlFieldName, IDictionary<string, object> htmlAttributes, string labelText = null)
        {
            var str = labelText …
Run Code Online (Sandbox Code Playgroud)

razor c#-4.0 asp.net-mvc-3

14
推荐指数
1
解决办法
2万
查看次数

WCF底层连接已关闭:接收上发生意外错误

我正在使用RestClient应用程序与我的WCF服务进行通信.我收到以下异常

The underlying connection was closed: An unexpected error occurred on a receive.
Run Code Online (Sandbox Code Playgroud)

这是我使用的C#代码

            string q = string.Format(@"xxxxxxxxxxxxxxxxxxxxxxxxxxx");
            WebClient client = new WebClient();
            string Url = string.Format("{0}/Get?queries={1}", BaseUrl,HttpUtility.UrlEncodeUnicode(q));
            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            var result = client.DownloadString(Url);
            Console.WriteLine("======================output================================");
            Console.WriteLine(result);
            Console.WriteLine("===========================================");
Run Code Online (Sandbox Code Playgroud)

这是错误消息

System.Net.WebException was caught
  HResult=-2146233079
  Message=The underlying connection was closed: An unexpected error occurred on a receive.
  Source=System
  StackTrace:
       at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
       at System.Net.WebClient.DownloadString(Uri address)
       at System.Net.WebClient.DownloadString(String address)
       at RestClient.Program.GetRecordsTest() in C:\Users\Wiemon\Downloads\RestAppClient\RestAppClient\Program.cs:line 118
  InnerException: System.IO.IOException
       HResult=-2146232800
       Message=Unable to read data from …
Run Code Online (Sandbox Code Playgroud)

c# wcf wcf-rest

7
推荐指数
2
解决办法
2万
查看次数

MVC3剃须刀Webgrid分页和排序超过2000条记录

我正在使用类似于此处提到的webgrid

@{
    var grid = new WebGrid(canPage: true, rowsPerPage: ThisController.PageSize, canSort: true, ajaxUpdateContainerId: "grid");
    grid.Bind(Model.Employees, rowCount: Model.TotalRecords, autoSortAndPage: false);
    grid.Pager(WebGridPagerModes.All);
    @grid.GetHtml(htmlAttributes: new { id="grid" },
        columns: grid.Columns(
            grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { EmployeeID = item.EmployeeID })),
            grid.Column("FullName"),
            grid.Column("Title")
        ));
}
Run Code Online (Sandbox Code Playgroud)

但在我的情况下,我期待超过2000条记录,我想加载每页只加载50条记录,以便页面加载速度更快.如何确保在加载页面时仅加载前50条记录.当我的用户单击page2时,我想加载下一组50条记录,依此类推.你们中的任何人都遇到过类似的问题,请给我一些示例代码

sorting paging webgrid razor asp.net-mvc-3

5
推荐指数
1
解决办法
2万
查看次数

如何在我的 blob 容器中创建一个空文本文件

如何在我的 blob 容器中创建一个空文本文件(或带有一些消息的文本)

var destBlob = blobClient.GetBlobReference(myblob);
Run Code Online (Sandbox Code Playgroud)

类似于 https://myxyzstorage.blob.core.windows.net/mycontainer/newfolder/newTextfile.txt

c# azure-storage-blobs

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