Posts

Donate

This version of Visual Studio requires the April 2014 update to Windows 8.1 (VS 2015)

Hello, Now that I've got the time to install Visual Studio 2015 Enterprise on my laptop with Windows 8.1 Operating System I decided to give it a go. That's when the moment I opened the installer file, an issue pops out of the screen with the description " This version of Visual Studio requires the April 2014 update to Windows 8.1 and Windows Server 2012 R2 known as KB2919355 ". The solution to this issue can easily be found at stackoverflow. But missing the links of the packages needed to resolve the problem. A step by step example is presented below. 1. Download update package 2919442 and install update to your pc. This is the pre-requisite update of package 2919355     x86     x64 2. Download update package 2919355 and install update to your pc.     x86     x64 3. After those updates have been installed, restart the computer for the updates to take effect. Cheers! :-)

How To Post JSON Data With WebRequest In .NET

Hello, There was a question on how to post a JSON data using the WebRequest class on both C# and VB.NET given that using Ajax, the post data would look like this. data : '{ "age": "78", "weight": "51" }' In .NET, you need to store the JSON data into a string object and escape those double quotes before passing it to the WebRequest object. C#.NET string postData = "{ \"age\": \"78\", \"weight\": \"51\" }" ; VB.NET Dim postData As String = "{ ""age"": ""78"", ""weight"": ""51"" }" Cheers! :-)

Sorting Of <li> Elements Using jQuery sort() Method Not Working (Refresh Page Only) In ASP.NET

Given the simple sorting code below which changes the order of <li> elements to ascending order and assuming that the text content of each li elements are numbers. $( function () { $( '#sortList' ).click( function (e) { // Select all the li items var numbersList = $( '#numbersList li' ); numbersList.sort( function (a, b) { return parseInt ($(a).text(), 10 ) > parseInt ($(a).text(), 10 ); }).appendTo(numbersList.parent()); }); }); The code should work only to find out that the page will only refresh after the button click. And then the re-arranging of the elements are discarded. The simple fix to this issue is to add the preventDefault() to prevent the button's default behavior that is to post back. $( function () { $( '#sortList' ).click( function (e) { e.preventDefault(); var numbersList = $( '#numbersList li' ); numbersList.sort( function (a, b) { var temp1 = parseInt($

$.getJSON() Not Loading JSON File Within Visual Studio Project In ASP.NET Web Forms

Hi, I was trying to load a JSON file located within my Visual Studio project using $.getJSON(), however the code below doesn't work as expected. $.getJSON( '/Assets/misc/employee.json' , function (data) { alert( 'processing!' ); }) .done( function (r) { alert(r.message); }) .fail( function (s) { alert( 'oops the file is missing!' ); }); After investigating for a few hours, I tested the local path of the JSON file such as http://localhost:3766/Assets/misc/employee.json and the result was an exception " HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map. ". I remember the solution in one of my ASP.NET project was to set the MimeMap in the web.config inside the system.webServer element. After setting the MimeMap for json files, I can now load local JSON files using $.getJSON(). <system.web

Visual Studio Showing Only "Attach" And No Debug Options In ASP.NET Project

Hello, Last night my computer shuts down unexpectedly due to power outage and when I opened an ASP.NET project this morning, it only shows "Attach" in the debug options. Running to different browsers such as Google Chrome, Firefox and Internet Explorer were missing. After a few search, I encountered a solution which is to set again the ASP.NET Project as StartUp Project by right clicking the project and selecting the option Set as StartUp Project . That's it.. :-)

Set An Html.RadioButtonFor() Helper As Default Checked In ASP.NET MVC

Good day! Given that you have to set a radio button as default checked in razor view, a code to do that is presented below using conditional ternary operator. However, there is an issue with the code shown below. Even if you set the checked property with empty string, it will still render as checked during run-time. @foreach ( var answer in item.Answers) { <p> @Html.RadioButtonFor(m => answer.ID, true , new { @disabled = "true" , @Name = item.ID, @checked = (answer.IsCorrect) ? "checked" : "" })@answer.AnswerText </p> } To ignore that issue, there are several ways to fix that. First one is to use if statement in the view itself . @foreach ( var answer in item.Answers) { <p> @if (answer.IsCorrectAnswer) { @Html.RadioButtonFor(m => answer.ID, true , new { @disabled = "true" , @Name = item.ID, @checked = "true" })@a

How To Handle ASP.NET GridView TemplateFields Null Values In Aspx Markup

Hello, To handle null values in GridView TemplateFields through aspx/html markup rather than code-behind, you can simply use the language operators to those fields. One approach is to use the conditional ternary operator in C# and VB.NET. The sample codes below illustrates how to do in C# and VB.NET. For C#, use the (?) operator. While VB.NET uses If() operator. C#.NET Code <asp:TemplateField HeaderText= "Name" SortExpression= "EmpName" > <ItemTemplate> <asp:Label ID= "lbl" runat= "server" Text= '<%# Eval("EmpName") %>' ></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID= "txtEmployee" runat= "server" Text= '<%# Eval("EmpName") == System.DBNull.Value ? string.Empty : Eval("EmpName").ToString() %>' ></asp:TextBox> </EditItemTemplate> </asp:TemplateField> VB.NET Code <as

View In ASP.NET MVC Not Refreshing After Calling Ajax Post In jQuery UI

Hello, In an application wherein the controller is invoked using Ajax POST and that controller will redirect to a landing page such as Index after processing, an issue will occur such as the View of that landing page isn't updated or not refreshed. Normally, the View will be updated since the model is queried from the database. [HttpPost] public ActionResult Delete( int id) { try { Customer customer = _customer.Customers.FirstOrDefault(t => t.CustomerID == id); if (customer != null ) { _customer.Customers.Remove(customer); _customer.SaveChanges(); } } catch { //TODO } return RedirectToAction( "Index" ); } The fix for that is to change the RedirectToAction() statement to return the url of a landing page as JSON result. And in the ajax statement, add a statement that navigate to the url returned from the controller. [HttpPost] public ActionResult Delete( int id) { try { Customer customer = _customer.Customers.FirstOrDefault(t =>

Url Variable Returns Forward Slash "/" instead of absolute Url in Controller Action

Hi, When passing a url from a controller action to an Ajax $.post() result that is to navigate to the landing page, using the code below generates only a forward slash which is the root symbol instead of an absolute url. If the url value (/) will be used in window.location.href , it will cause an IIS page not found error. var url = new UrlHelper(Request.RequestContext).Action( "Index" , "Customer" ); return Json( new { Url = url }); So, to return the absolute url of the controller action in the current context, replace UrlHelper class with Url.Action() method. It is important to include the Request.Url.Scheme in the parameter to pass the correct protocol of the url. The code below will return an absolute url such as: http://localhost:7088 for the landing page. var url = this .Url.Action( "Index" , "Customer" , null , Request.Url.Scheme); return Json( new { Url = url });

window.location.href not opening website

Hello, The code below does not open the link, instead opens a blank page or IIS error. This issue occurs in all major browsers. window.location.href = 'www.nba.com' ; In order to fix the issue,you must prepend the correct protocol before the website such as (http:// or https:// or ftp://). If the protocol is omitted, the link is interpreted as a file in the website. window.location.href = 'http://www.nba.com' ; Cheers!

Donate