Wednesday, 25 February 2015

Free ebooks from Microsoft Press: Microsoft Azure Essentials: Fundamentals of Azure

Microsoft Azure Essentials: Fundamentals of Azure
Michael S. Collier and Robin E. Shahan
February 2015



The “Microsoft Azure Essentials” series helps you advance your technical skills with Microsoft Azure. “Microsoft Azure Essentials: Fundamentals of Azure” introduces developers and IT professionals to the wide range of capabilities in Azure. The authors—both Microsoft MVPs in Azure—present conceptual and how-to content for seven key areas and describe management tools and business cases.



Monday, 9 February 2015

How to clear/reset dropdownlist Using JQuery

Hi Folks,

While Working with Drodownlist's today i faced one problem it is not clearing the Old data.
Then realised to clear the data except default value using jQuery

My asp.net MVC Razor Code:



@Html.DropDownList("City", (IEnumerable<SelectListItem>)ViewBag.Cities, "--Choose Your City--", new { @id = "ddlCity", @style = "width:200px;" })

and Javascript section as below



@section Scripts {
    <script type="text/javascript">
function GetCities(_Id) {              
            var ddlcity = $("#ddlCity");   
            $.ajax({
                cache: false,
                type: "GET",
                url: '@Url.Action("GetCities", "Admin")',
                data: { "id": _Id },
                success: function (data) { 


   //Clearing the Data except first default value.

                    ddlcity.children('option:not(:first)').remove();
                    $.each(data, function (id, option) {
                                      ddlcity.append($('<option></option>').val(option.id).html(option.name));
                    });
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert('Failed to retrieve Cities.');

                }
            });
        }
    </script>
}