Engineering

How to get Active Directory connection string in C#.NET

First you will have to add a reference for System.DirectoryServicesYou must run the application on a machine within the same domain to be able to connect to the Active Directoryusing System.DirectoryServices;private string GetActiveDirectoryConnectionString() { DirectoryEntry root = new DirectoryEntry("LDAP://RootDSE"); using (root) { string dnc = root.Properties["defaultNamingContext"][0].ToString(); ...

How to add windows forms control in WPF

I will describe how we can use windows forms controls in WPF application.I'll assume I have a WPF Application and I want to use DateTimePicker Control, how I can do that in WPF Application?1- Create WPF Application.2- Add Stackpanel control.3- in Solution Explorer Add Reference for:System.Windows.FormsWindowsFormsIntegrationusing WindowsControls = System.Windows.Forms; using WindowsIntegration...

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack ASP.NET

While I was debugging an ASP.NET Application, I wanted to get an object values I got this error message instead:"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"This problem occurs when using Response.Redirect or Server.Transfer method, because the Response.End method...

Adding the specified count to the semaphore would cause it to exceed its maximum count

I got this unusual exception while working on an ASP.NET project:"Adding the specified count to the semaphore would cause it to exceed its maximum count error".I thought it is something related to SQL Server Database Connection String.After using Query Profiler I was able to run SQL queries directly without any...

How to disable some context menu items on Telerik TreeView

There is an event named "OnClientContextMenuShowing" for Rad Treeview that calls javascipt function and passes 2 arguments "sender, args".The Args parameter contains The current selected TreeNode and Context Menu Items.You can enable or disable any Context menu item based on any attributes for the Current Selected Tree Node.Here is a...

How to get year, month and say out of SQL Date in SQL Server

Let is say that we have the following Date 2007-04-05 10:13:14.109 and we want to get Year, Month and Day out of this date.There is a function named DATEPART() that can be used to archive this.DECLARE @MyDate AS DATETIME SET @MyDate = '2007-04-05 10:13:14.109' SELECT DATEPART(DAY, @MyDate) AS MyDay, DATEPART(MONTH, @MyDate) AS MyMonth, DATEPART(YEAR,...

How to avoid Uncaught ReferenceError: $ is not defined in jQuery

Sometimes while developing an existing Web Application, I wanted to use jQuery function and I got this error "Uncaught ReferenceError: $ is not defined".There are some reasons causing it and ways to avoid them:Make sure the references to the jQuery scripts is loading first, but them in the head of master page or...