How to remove a MenuItem base on condition

There may be an easier solution, which is to use the MenuItemDataBound event. I use this to hide menu nodes from the Menu Controller . Keeping them in the siteMap allows them to appear in the Menu Controller , but I don't want them in the Menu Controller based on the Roles attribute . Here's my code: The SiteMap File <?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="" >     <siteMapNode url="" title=""  description="">         <siteMapNode url="#" title="Home" roles="*"  description="This is Homepage" />         <siteMapNode url="" title="About" roles="*"  description="This About Page" />         <siteMapNode url="_#" title="Product" roles="ADMIN" description="This is Product Page, Only Role Admin Can access"

Get Files from Directory - C#

This example shows how to get list of file names from a directory (including subdirectories). You can filter the list by specific extension. To get file names from the specified directory, use static method Directory.Get­Files . Lets have these files and subfolders in „c:\MyDir“ folder: Get files from directory Method Directory.GetFiles returns string array with files names (full paths). using System.IO; string [] filePaths = Directory .GetFiles ( @"c:\MyDir\" ); // returns: // "c:\MyDir\my-car.BMP" // "c:\MyDir\my-house.jpg" Get files from directory (with specified extension) You can specify search pattern. You can use wildcard specifiers in the search pattern, e.g. „*.bmp“ to select files with the extension or „a*“ to select files beginning with letter „a“. string [] filePaths = Directory.GetFiles(@"c:\MyDir\", "*.bmp"); // returns: // "c:\MyDir\my-car.BMP" Get files from directory (including all subdirectories) If you want

ASP.NET - MSSQL Server Database Timeouts

One of the most disturbing aspect of most database applications is connection timeouts. Most of us might have faced this at one time or other. It would be helpful if we have complete control over the timeout and execution of our database queries/procedures. There are 3 different places that you need to check if you face a timeout in your application. Let us say, you have an application that runs a lengthy stored procedure and you started getting a timeout error. You tried to optimize the procedure to the maximum possible extend. At this stage, it is desirable to have a way to extend the timeout so that the user will see the results even after waiting for a little longer. Database Timeout Settings The first place that you need to check is your database server, to see if the server accepts long running queries/procedures. You can do this by checking the properties of the database. If you are using enterprise manager right click on the server name and select properties.

C# Method to Convert ASCII to EBCDIC vice versa

This example show convertion between ASCII character to EBCDIC character and EBCDIC to ASCII. ASCII To EBCDIC public string ConvertASCIItoEBCDIC(string strASCIIString) {      int[] a2e = new int[256]      {         0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15,         16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31,         64, 79,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97,         240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111,         124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214,         215,216,217,226,227,228,229,230,231,232,233, 74,224, 90, 95,109,         121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150,         151,152,153,162,163,164,165,166,167,168,169,192,106,208,161, 7,         32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27,         48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,225,         65, 66, 67, 68, 69, 70, 71, 72, 73, 81, 82, 83, 84, 85, 86, 87,       

7 way to convert DataTable to generic List - C#

Conversion DataTable to Generic List<t>. We can do it in various way. Solution 1: DataTable dt = CreateDataTable(); List<datarow> list = new List<datarow>(); foreach (DataRow dr in dt.Rows) {      list.Add(dr); } Solution 2: DataTable table = new DataTable { Columns = { {"Foo", typeof(int)}, {"Bar", typeof(string)} } }; for (int i = 0; i < 5000; i++) {      table.Rows.Add(i, "Row " + i); } List<T> data = new List<t>(table.Rows.Count); foreach (DataRow row in table.Rows) {       data.Add(new T((int)row[0], (string)row[1])); } Solution 3: Using Linq expression. It return data in List<t>. List<string> list =dataTable.Rows.OfType<datarow>().Select(dr => dr.Field<string>(0)).ToList(); Solution 4: Using Linq/lamda expression. List<employee> list= new List<employee>(); list = (from DataRow row in dt.Rows select new Employee {      FirstName = row["ColumnName"].ToString(),      Last

Configure IIS 7.5 to manage ASP.NET 4.0 web pages

Problem Solution After installing .NET Framework 4.0 on a machine there is a few configuration changes you need to do to IIS in order to get a ASP.NET 4.0 page running. First set the Application pool to run in ASP.NET v4.0 “mode”. Then you need to allow ASP.NET v4.0.x to run. This is done in the ISAPI and CGI Restrictions found on the server level. Follow The picture below to make it done.. 1) 2 ) 3) 4) Select the same version you have installed on your server, (32 bit or 64 bit). And change to Allowed.  By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Arranging DIVs Horizontally

Working with DIV tag is always problem and hard work thats why many web developers avoid creating their websites in DIV tag, in this tutorial, I will show you how to arrange DIVs in horizontal order with CSS. The HTML Code This is the html code for 4 divs div.container, div.left, div.middle and div.right. Note: Below the div.right there is another div with height:0; and width:100% and clear:both, the job of this div is to make sure the floating divs not going outside the container, try on your own to remove the div.clear to see what will happen on those floating div.    <div class="container">    <div class="left">Left</div>    <div class="middle">Middle</div>    <div class="right">Right</div>    <div class="clear"></div>    </div> The CSS Code .container{ width:600px; padding:0; border:5px solid #ddd; margin:0 auto; } .left{ float:left; width:150px; height:300px; te