Get Url Reference -

This is just for reference to get the URL based on HttpRequest Class. You can call the method below : Request.ApplicationPath :   /virtual_dir Request.CurrentExecutionFilePath :  /virtual_dir/webapp/page.aspx Request.FilePath :  /virtual_dir/webapp/page.aspx Request.Path :  /virtual_dir/webapp/page.aspx Request.PhysicalApplicationPath :   d:\Inetpub\wwwroot\virtual_dir\ Request.QueryString :   /virtual_dir/webapp/page.aspx?q=qvalue Request.Url.AbsolutePath :  /virtual_dir/webapp/page.aspx Request.Url.AbsoluteUri :   http://localhost:2000/virtual_dir/webapp/page.aspx?q=qvalue Request.Url.Host :  localhost Request.Url.Authority : localhost:80 Request.Url.LocalPath : /virtual_dir/webapp/page.aspx Request.Url.PathAndQuery :  /virtual_dir/webapp/page.aspx?q=qvalue Request.Url.Port :  80 Request.Url.Query : ?q=qvalue Request.Url.Scheme :    http Request.Url.Segments :  /     virtual_dir/     webapp/     page.aspx By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciat

Kentico 8.1 - Custom Upload Form Control [Solved to support custom table to store image/binary stream data]

Kentico is a powerful CMS engine that allow you to developed portal very fast. But when you have a really big data such as (10,000 above), you may need to think a different way to store the data(Not put all document as a Page Menu Item). I have heard kentico have test their product for 100K document. But from my experience using shared server, it is cause a lot of painful if you want to expand the node in your page module, and even very slow to load the data.(That is my situation). So after all, I have decided to developed a " Custom Upload FormControl " to make Custom table support for upload files/media. This implementation is quite tricky because the custom formcontrol just store link to custom table field and it will store the image into media library folder. Look at the flow below : User/admin upload image using custom formcontrol Custom formcontrol check folder in media library, if not exist, create media library folder.(Each user will have their own folder so in future

Adding control dynamically from Code Behind - Dropdown, Listbox, Checkbox -

This tutorial/example shows how you can add control dynamically from code behind. This example not only limits to Dropdown, Listbox, and Checkbox controls, but you can use this example for any controls. The only things that you need to understand the process. Step By Step Create one new project name DynamicControls Add One web form or webform using the master page if you use the default template master page. Copy-paste code below respectively. (Note: I'm using the default master page template from VS2010) ASPX code   <h3>         This is Dynamic Control Tutorial     </h3>     <asp:Button ID="Button1" runat="server" Text="Add ListBox To Panel"         onclick="Button1_Click" />     <br />     <asp:Button ID="Button2" runat="server" Text="Add Dropdown To Panel"         onclick="Button2_Click" />     <br />     <asp:Button ID="Button3" runat="server&q

Await in Catch and Finally

This is just a brief note to publicize a coming improvement to the async language support. With the new compilers, changes to the C# language (e.g., async/await) are easier than they used to be. One improvement that is coming is the use of await in catch and finally blocks. This enables your error-handling/cleanup code to be asynchronous without awkward code mangling. For example, let’s say that you want to (asynchronously) log an exception in one of your async methods. The natural way to write this is: try {   await OperationThatMayThrowAsync(); } catch (Exception ex) {   await MyLogger.LogAsync(ex); } And this natural code works fine in Visual Studio “14”. However, the currently-released Visual Studio 2013 does not support await in a catch, so you would have to keep some kind of “error flag” and move the actual error handling logic outside the catch block: Exception exception = null; try {   await OperationThatMayThrowAsync(); } catch (Exception ex) {   exception = ex; } if (except

HEX to ASCII and ASCII to HEX Class - C#

This article shows you how to convert string to hexadecimal and vice versa. HEX TO ASCII Class using System.Collections.Generic; using System.Text; using Microsoft.VisualBasic; // I'm using  this class for Hex Converion namespace Hex_Converter {     public class HexConverter     {         public string Data_Hex_Asc(ref string Data)         {             string Data1 = "";             string sData = "";             while (Data.Length > 0)             //first take two hex value using substring.             //then  convert Hex value into ascii.             //then convert ascii value into character.             {                 Data1 = System.Convert.ToChar(System.Convert.ToUInt32(Data.Substring(0, 2), 16)).ToString();                 sData = sData + Data1;                 Data = Data.Substring(2, Data.Length - 2);             }             return sData;         }         public string Data_Asc_Hex(ref string Data)         {             //first take each charct

Message Box Class - Confirm,Error, Warning and Info - C#

A C# Snippet for creating Message Box with various type of message (Confirm,Error, Warning and Info). Message Box Class using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace messageBox {     public static class MsgBox     {         // Displays a Confirm type message box             // parameter name="sMsg" is The message you want to display         public static bool Confirm(string sMsg)         {             return Confirm("Confirm :", sMsg);         }         public static bool Confirm(string sTitle, string sMsg)         {             DialogResult ret = MessageBox.Show(sMsg, sTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question);             return (ret == DialogResult.Yes);         }         //---------------------------------------------------------------------         // Displays a Error type message box               // parameter name="sMsg" is The message you want to display         public stati

Convert Hex / Css String color to .NET Colour (RGB)

Have you facing problem to convert "#CCCCCC" to .NET Colour.? Here is a solution to convert the CSS / Hex String to .NET Colour (RGB). Conversion Class using System; using System.Collections.Generic; using System.Text; using System; using System.Drawing; using System.Text.RegularExpressions; namespace Convert_Hex_String_to.NET_Color {     public class ConversionClass     {               /// <summary>         /// Convert a hex string to a .NET Color object.         /// </summary>         /// <param name="hexColor">a hex string: "FFFFFF", "#000000"</param>         public static Color HexStringToColor(string hexColor)         {             string hc = ExtractHexDigits(hexColor);             if (hc.Length != 6)             {                 // you can choose whether to throw an exception                 //throw new ArgumentException("hexColor is not exactly 6 digits.");                 return Color.Empty;