Posts

AngularJS caching issue for Internet Explorer for Ajax (GET) requests

Generally we face the cache issue for particularly internet explorer in angularJs when we use $http to get the data from the server.The reason for this problem is when we request the same call again to the server , IE fetches the response from the cache instead from updated result. This can be shown clearly from the network capture window of IE. When we request the server for the first time the response code would be 200(OK) , if we make the same call again , we would get response code as 304 ( Not Modified ) . To fix the above problem we can plug few settings to the main angular module  or to each HTTP get request. var myApp = angular.module('myApp', ['ngRoute']); myApp.config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider) {     $httpProvider.defaults.cache = false;     if (!$httpProvider.defaults.headers.get) {       $httpProvider.defaults.headers.get = {};     }     // d...

Allow Video format to play in MediaPlayer

Image
This is a common problem with video format type to play in the web site/web applications if we use the media player. In this article, I would like to give a simple solution to allow the “*.mp4” format video files to play in the media player in our web application in the IIS.   This video file format is not allowed in the IIS under MIME type. The following steps are done in the Internet Information Server (IIS).   Step# 1 Start IIS Manager Select the appropriate website to which we want to allow “mp4” format, then click MIME types Step# 2 Click on Add  Step# 3 Enter the video format information File name extension: .mp4 MIME type: video/mp4  Step# 4 Restart IIS.

Suppress the warning messages in Visual Studio

Image
Sometimes we might have seen the warning message when we build the solution. These warning won't stop your application execution in fact these are most useful to preventing the defects. In order to suppress this warning message we need to use the pre-processor directives i.e., "#pragma warning" . Example : As shown in the below image , the variable count is assigned and didn't used that value any where. When we build the project able to see a warning in the Error List window. To overcome this warning we need to define the pragma warning pre-processor directive to the variable as shown below. #pragma warning disable   int count = 1; #pragma warning resotre   Hope this article helped you to supress the warnings in visual studio :-)  

Column COLLATION can affect SQL Server query performance ?

I found an interesting article on column collation in SQL Server. Please refer this Column Collation article from SQL Server Tips site.

Exporting to excel from a custom class object using C#.NET

We may face a scenario to export the data of custom class object to excel using InterOp .You can get the property name's from the class object using Reflection.Create a work sheet header by reading the each propety of the class object.I have created a separate method to get the all properties into a list collection of string as given below         ///         /// Get the list of Properties Name into a list collection.         ///         ///         ///         public List GetPropeties(Employee objEmployee)         {             Type myType = objEmployee.GetType();             IList props = new List (myType.GetProperties());  ...

How to fix "Sys is undefined" error ?

Image
Recently I have faced a strange issue in the process of developing a task using script manager for async post backs. The error is " webresource.axd and scriptresource.axd 404 not found " whenever I do any async call I use to get this error " sys is not defined ". I have tried a lot to fix this issue by following the below links. 1. http://blogs.msdn.com/b/carloc/archive/2008/12/04/webresource-axd-or-scriptresource-axd-not-working.aspx 2. http://imnettellect.blogspot.in/2010/12/iis-75-webresourceaxd-and.html 3. http://stackoverflow.com/questions/1433512/asp-net-web-application-webresource-axd-and-scriptresource-axd-files-loading and so on .... After spending 4 hours I found a new property on asp.net 4.0 called EnableCdn that basically, if it's set to "true", it loads the resources from the Microsoft content resource servers. Refer this link for information about EnableCDN . This worked like a charm and fixed my issue. I hope this snippet can help...

How to hide bootStrap popover when user click(s) outside the popover?

Hiding bootStrap popover when user click(s) outside the popover Recently I have experienced this problem i.e., hiding the popover when we click outsode the popover.I have worked on it and fixed the issue.So,I thought to share this fix. For more detail(s) about the bootStrap please refer this link PopOver popover plugin has a property called " trigger " of type String with default event as " click " and popover can be triggered by click/hover/focus/manual.  To show the popover we need to prepare the HTML mark-up as given below < div class = " btn-group " > < div class = " btn-group " id = " ddlSelected " style = " clear: both; " > < button class = " btn btn-primary btnSelectedStyle selectedBorderStyle " type = " button " > Your selected Items ( < b id = " lblSelectedItemCount " > 0 < / b > ) < / butt...

Why Dispose() is preferred than Finalize() for Un-Managed Resources in .NET?

Image
Memory management is very important in any application development.The Garbage collector of .NET does almost all clean up activity for your objects.For unmanaged resources (Ex:Windows API created objects, File, Database connection objects, COM objects, etc.) are outside the scope of .NET framework. Why Dispose() is preferred than Finalize() If we use the " Finalize() " method,the  Garbage collector has to make two round in order to remove the objects. For an instance ,let me explain clearly if we have two objects as Object1 and Object2 and we finalize the Object2 as given in the below image.The GC has to categorize the two objects and put the Finalize objects into Finalization Queue.The GC will clean the object1 which doesn't use the Finalize() method and process the second round of cleaning the Finalization Queue. Now at this the " Dispose() " method will come into picture.This method belongs to IDisposable() interface .So the best practise to...

Detailed Table using jQuery

Image
We have seen in many sites regarding detailed information of products below the row when we click on the downwards arrow and collapse when click on upwards arrow. We have many plugin's for this type of functionality we can also do with jQuery simple logic also. I have done some R&D regarding this and want to share information of detailed table using jQuery. We need to download the latest jQuery File from this link http://jquery.com/download/ We have many CDN links also available for directly accessing the jQuery library files. Google : https://developers.google.com/speed/libraries/devguide#jquery Micro-soft : http://www.asp.net/ajaxlibrary/cdn.ashx Git-hub: https://github.com/jquery/jquery

How to use constants in .NET?

I have a written this Dev tip for the new folk who entered in this Dev World. Normally in the development we use some of the success message's or failure messages in general common message's.We do have a habit of writing the messages as given below MessageBox.Show("Successfully created a record!"); MessageBox.Show("Successfully deleted a record!"); We can make use of Constants in .NET which will be declared using the keyword " const ".For the above scenario we can create a  class like "Messages.cs" and define constants as given below  public class Messages     {         public const string strUserExist = "User Name already exists.";         public const string strUserSaved = "User information saved successfully.";         public const string strUserDeleted = "User deleted successfully.";         } ...

Difference between Debug and Release Modes in Visual Studio

Difference between Debug and Release Modes in Visual Studio We have two options to build a application in production or development stage.Both have their own importance's and characteristics . Debug :Developer use debug mode for debugging the web application on live/local server.Debug mode stores debug information so it takes time to execute.We can use F10,F11 function keys as well keep tracking the break point.In debug mode the *.pdb (Program debug database) file will be created which contains the debug steps in the binary format.Less optimized code. Release : We can't do the debug in this mode ,hence no chance of creating *.pdb file.Scripts & images downloaded by webresource.axd are cached.It has small size, and runs fast.More optimized code. I hope this information could help folks. Happy coding :-)

Get the SQL Server Information from Query

Some times we need to get the information of the SQL Server where it is installed. Simply we can get the info from Query also -- Get the version info select @@version We have a in-built stored procedure called 'xp_msver' to the Server information. -- Get the Server Information exec xp_msver This is a basic information provided but may be useful to the SQL Server learners . Good day :-)

How to update Row which is not having Primary Key?

We all find some different scenario where the table has no primary key column and need to update the records having same data. For this type of scenario's we need to update the particular column based on some Unique value.In SQL Server we have a option called " ROW_NUMBER() " .Every one know about Row_Number() I will present a brief intro about this. ROW_NUMBER():   ROW_NUMBER to find the Row number of a particular column if its specified in orderby Clause.It has the following syntax  Syntax: select  row_number() over (order by name) as ROWNumber, Name from sys.all_objects order by name  For more details about the R OW_NUMBER() refer this MSDN .   Here I will present a example query to update a table which has no primary key and having same data for few rows . WITH Record AS (select  row_number() over (order by [columnName]) as ROWNumber, Name from sys.all_objects order by name )  UPDATE Record set [col1]=@col1,[co...

Programmatically Zip and UnZip the files in .NET

Normally we may find the functionality to Zip and Unzip the file pro grammatically.We have many third party components to do this operation.Here I am going to present Zip and Unzip files using "CGZipLibrary.dll" in C#.NET. To do this we need to download the CGLibrary.dll from this link and register this dll. The zip file contains 3 DLL's: CGZipLibrary.dll zip32.dll Unzip32.dll Open the command prompt in administrator mode.Now we need to register this CGZipLibrary.dll as given below regsvr32 filepath\filename Ex : regsvr32 D:\Download\CGLibrary.dll After registering the dll and Copy zip32.dll and unzip32.dll to c:\windows\system32 directory or c:\winnt\system32. Unzip the file you need to do like this            string SrcPath = @"D:\StudentReports.zip";             string DestPath = @"D:\ZippedFiles";          ...

Bind the Events to the Dynamically Created Rows in a HTML Table

I found a solution to bind the events to the dynamically created buttons in a HTML.Some times we need to add a row to the existing HTML table with some inputs.That dynamically created row is not visible in the page source.Try It ! So to attach the events also we need to do like this var newRow = " <tr> <td></td> <td><input type='text' id='tbNameDyn'/></td> <td> <input type='text' id='tbAgeDyn'/>< /td> <td><input type='checkbox' id='tbResultDyn'/></td> <td > <input type='submit' name='submitButton' value='Save Row' id='btnSaveRowDyn' onclick='DynButtonClick();'> </td></tr> " ; // $('#webgrid > tbody:last'). $ ( '#webgrid tbody:last' ) . append ( newRow ) ; Here I have binded the button with the event "onClick" function ...

Make the Textbox as Label using CSS

This is a simple tip to make the textbox as label in the Web Pages.We need to just add a simple CSS to the input text.See code snippet . textboxAslabel { border : none ; background-color : # FFF ; border-color : # FFF ; } Here I have mentioned the background-color and border-color as "white".In my application the background-color is white.So according to your background-color change it.Now Apply that to the textbox.See this Image

Single to handle multiple "Submit" button Clicks in MVC3 Razor View

Last week, I have faced a problem on handling the multiple "Submit"   buttons clicks in a View.I am not very good at MVC3 but I want to share my experience so that others can find some solution regarding this problem. Suppose we have many Submit buttons in a View where we want to handle the different functions. In the Controller of the We need to write the Code for different submit buttons as given below [ AcceptVerbs ( HttpVerbs . Post ) ] public ActionResult FormActions ( string submitButton ) { switch ( submitButton . ToLower ( ) ) { case " click to know date " : this . SetNotification ( DateTime . Now . Date . ToString ( " dd-MMM-yyyy " ) ,   NotificationEnumeration . Success , true ) ; return View ( " index " ) ; break ; case " click to know time " : ...

Difference between the SCOPE_IDENTITY(),@@IDENTITY and IDENT_CURRENT in Sql Server

SCOPE_IDENTITY(),@@IDENTITY and IDENT_CURRENT('table_name') are the SQL SERVER Functions which will return the last inserted record Identity Value. Normally in the development stage we need to get the last inserted row information using SQL Query. Lets go in deep to understand the differences between these three functions. @@IDENTITY : @@IDENTITY will return the Identity value generated in a table irrespective of the scope.The main advantage lies here when we have a trigger on a table that causes anidentity to be created in another table,you will get the identity that was created last since it gets the identity regardless of the table. Syntax : SELECT @@IDENTITY; SCOPE_IDENTITY(): SCOPE_IDENTITY() also returns the Identity Value generated in a table with in the same scope regardless of the table that produced the value. Syntax: SELECT SCOPE_IDENTITY(); IDENT_CURRENT('table_name'): It will returns the last Identity value produced in a table regardle...

Set the Default Value to the Column Of a Table Programmaticaly

Normally we face this type of problem when we want to set the column default value pro-grammatically. To Solve this problem we need to first get the table column information using this Query. "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='person'" . Here the table name may vary. when we execute this Query we will get the each column information . So based on this we can Iterate the each column and get the each column Information as given below        VB.NET  Private Sub Initialise_The_Table(ByVal ReqTab As String) On Error GoTo handle_error Dim eachTableAdapter As SqlDataAdapter Dim tableDataset As New DataSet Dim adoHelper As SQLHelper = SQLHelper.GetInstance eachTableAdapter = adoHelper.GetAdapter("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + ReqTab + "'") eachTableAdapter.FillSchema(tableDataset, SchemaType.Source, ReqTab) eachTableA...

Context Menu in ASP.NET

Image
We normally face a task like to show Menu when we right click the gridview or treeview e.t.c. Many third party controls are providing this right click context Menu to the controls like one of the best third party control like Telerik . But we can do this type of requirements using jQuery also. To do this in ASP.NET we need to download the jQuery Context Menu plugin. We need frame the menu div based on our requirement.See this example to do < div >      < ul id ="myMenu" class ="contextMenu" >        < li class ="edit" >< a href ="#edit" > Edit Node </ a > </ li >        < li class ="delete" >< a href ="#delete" > Delete Node </ a > </ li >      </ ul >    </ div > * This source code was highlighted with Source Code Highlighter . After downloading the plugin you need to add this l...