Technical

Custom validator scrolls page to the top in ASP.NET

If we add a ValidationSummary control to the page, its ValidationSummaryOnSubmit function invokes “window.scrollTo(0,0)” when page is invalid. That’s why the page scrolls to the top.To workaround this issue, we can assign a function to window.scrollTo which do nothing, so that window.scrollTo(0,0) will not take effect. This workaround is appropriate...

How to sort a whole XML document using XSL

This is a variation of an identity transformation that sorts all nodes and attributes alphabetically.<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"> <xsl:output method="xml" omit-xml-declaration="no"> <xsl:template match="@*|node()" priority="1"> <xsl:copy> <xsl:apply-templates select="@*|node()"> <xsl:sort data-type="text" order="ascending" select="name()"> </xsl:sort></xsl:apply-templates> </xsl:copy></xsl:template> </xsl:output></xsl:output></xsl:stylesheet>

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...