Author: Rizwan Ansari
Hyper-V vs VirtualBox
Hyper-V and Virtualbox are not in the same category. Below is a comparison chart between two. Hyper V Virtual Box Server virtualization Desktop virtualization Type 1 hypervisor. It’s headless virtualization that runs directly on the hardware Type 2 hyperviosr. Virtualbox requires an OS and is a virtualization application that runs on your desktop Hyper-V is […]
Flash Player in Server 2012
In order to run Flash player and other Desktop features, need to enable Desktop Experience. It is a Feature labeled “Desktop Experience” under “User Interfaces and Infrastructure” in “Add Role and Features Wizard” that is not checked by default. You need to check it and the server will restart twice.
HTTP Status Code in case of Exception
This is how to get HTTP Status code in case of an Exception during HttpWebRequest catch(WebException ex) { HttpWebResponse res = (HttpWebResponse) ex.Response; Console.WriteLine("Http status code: " + res.StatusCode); }
Visual Source Safe with Visual studio 2013
By default Visual Studio 2013 does not integrate with Visual SourceSafe. In order to activate VisualSource Safe in Visual Studio 2013 activate this in Tools -> Options -> Source Control -> Plug-in Selection and change the plug in to the Visual SourceSafe. Adding a solution to source control will launch the Visual SourceSafe.
JQUERY AJAX different ways
Below are different ways to perform AJAX Get and Post requests through jQuery. GET request method 1 $.ajax({ url: url, data: data, success: success, dataType: dataType }); GET request method 2 $.get( "ajax/test.html", function( data ) { $( ".result" ).html( data ); alert( "Load was performed." ); }); GET request method 3 – jqXHR // […]
Waiting for AJAX response
Below code will fade out all elements in a web page till AJAX completion of request. $("body").ajaxSend(function() { $(this).append('<div id="loading">Data Loading</div>'); $('#tag').children().not('#loading').css({'opacity':0.22}); }); $("body").ajaxComplete(function() { $("div#loading").remove(); $(#tag).children().not('#loading').css({'opacity':1}); });
ASP.NET GridView Paging and Sorting
Below is the sample to include Sorting and Paging in ASP.Net GridView. ASPX Code <asp:GridView ID="grd" runat="server" AutoGenerateColumns="False" AllowSorting="true" OnSorting="grd_Sorting" AllowPaging="true" PageSize="50" OnPageIndexChanging="grd_PageIndexChanging"> Code Behind protected void grd_Sorting(object sender, GridViewSortEventArgs e) { try { mDT = GetData(); SetSortDirection(SortDirection); if (mDT != null) { mDT.DefaultView.Sort = e.SortExpression + " " + _sortDirection; grd.DataSource = mDT; grd.DataBind(); […]
ASP.NET AJAX File Upload
jQuery can help in uploading a file on asp.net web page asynchronously. Add a generic handler in asp.net project like below. Upload Generic Handler – Code behind file (upload.ashx) public class upload : IHttpHandler { public void ProcessRequest(HttpContext context) { string fileName = HttpContext.Current.Request.QueryString["FileName"].ToString(); using (FileStream fs = File.Create("[Path]\\" + fileName)) { Byte[] buffer = […]
SQL Server Handle Transaction and Try Catch
SQL Server handles exceptions just like any programming language. Below is a stub to help understand SQL exception handling and you can use in your Procedures as a starting point. BEGIN TRAN BEGIN TRY EXEC P1 EXEC P2 COMMIT TRAN END TRY BEGIN CATCH ROLLBACK TRAN DECLARE @ErMessage NVARCHAR(2048), @ErSeverity INT, @ErState INT SELECT @ErMessage […]
C# snippets
Converting a string to byte-array without using an encoding (byte-by-byte) static byte[] GetBytes(string str) { byte[] bytes = new byte[str.Length * sizeof(char)]; System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); return bytes; } static string GetString(byte[] bytes) { char[] chars = new char[bytes.Length / sizeof(char)]; System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length); return new string(chars); } Using String Format to […]