CSS/DHTML/JavaScript

Angular JS vs Knockout JS -quotes and links

Our team need to choose a JS framework. Base on the research Angular is the preferred framework. The only essential concern - if you need to support old IE6/7 browsers(but also there are articles how to support/workaround the IE issues)From http://www.quora.com/JavaSc... supports almost all major browsers:IE6+, Firefox 2.0+, Chrome, Safari and Opera 10+.Link - Knockout : Browser supportAngular Supports only A grade browsers at the moment:IE8 ......

Log JavaScript errors to the server.

Some time ago I found debugging - Automatic feedback on JavaScript error - Stack Overflow. and the discussion has links to Logging JavaScript Errors To ASP.NET(Unfortunately the link to download in the post is broken).and custom control to help log JavaScript errors by sending error information to the server -thecodepage.com/post/JavaS... downloaded solution from JSErrorNotifier.zip. When I wanted to include dll into my solution dependencies, I decided to rename WebControls.DLL ......

Select tool to minimize JavaScript and CSS size

There are multiple ways and techniques how to combine and minify JS and CSS files.The good number of links can be found in http://stackoverflow.com/qu... and in http://www.hanselman.com/bl... There are 2 major approaches- do it during build or at run-time.In our application there are multiple user-controls, each of them required different JS or CSS files, and ......

Translate jQuery UI Datepicker format to .Net Date format

I needed to use the same date format in client jQuery UI Datepicker and server ASP.NET code. The actual format can be different for different localization cultures.I decided to translate Datepicker format to .Net Date format similar as it was asked to do opposite operation in http://stackoverflow.com/qu... Note that replace command need to replace whole words and order of calls is importantFunction that does ......

Syncronize IIS servers in a web farm to enable ETags

It’s known that on web Farm using of eTags under IIS doesn’t work properly unless all servers are synchronized.http://support... suggests to synchronize the ETag values on all the Web servers that are running IIS using Mdutil.exe that should be extracted from Windows CDhttp://developer.yahoo.co... to use iiscnfg.vbs script (with the /copy switch) to keep cluster configuration synced up, this keeps the MDETAGCHANGENUMBER ......

Javascript coding style recommendation: in return and throw statements use only simple variables

My collegue told me that placing the opening curly brace at the end of the line is safer than at the beginning of the new line, because it prevents some hard-to-debug errors, related to Automatic Semicolon Insertion and pointed me to the article Basic JavaScript Part 6: Automatic Semicolon Insertion. The article has the recommendation Trying to outline curly braces at the end of the line can save you some headaches in case a semicolon is forgotten somewhere in the code.The statement is misleading ......

Internet Explorer 9:IE 7 standards accidental change

One of our testers reported, that many pages are not working correctly in her IE9 browser. It took me a while to find out that in development tools it was set Document Mode:IE7 standards. The option has a shortcut -Alt-7, but it works only if development tools(F12) are opened. I couldn't understand, how the setting was changed accidentally.If it’s possible, many IE users will have unexpected problems ......

Change DocType dynamically

I have a single page(created before Master pages were available) that loaded dynamically one or another user control.Some child controls have css for quirk mode, but for new controls I want to use latest DocType <!DOCTYPE html> The solution is to set it dynamically in code-behind depending on current control to load(the code is copied from http://stackoverflow.com/qu... =========aspx=============== <%@ Page Language="C#" ......

Set Offset to not attached div doesn't work correctly in IE

We want to dynamically show an image below a span html element. The javascript creates a div element, than assigns new offsets using jQuery offset() and then appends the div to document.It worked as expected in FireFox, but moved the new element to the bottom of the page in IE.I found, that if I will call offset after document.body.appendChild, it will assign values correctly.In the test page below if offset is called after document.body.appendChild, new img assigned left: -8, top: 110img left: -8, ......

JavaScript function to Redirect parent of IFrame to specified URL

/// <summary> /// Redirects parent of IFrame to specified URL /// If current page doesn't have parent, redirect itself /// </summary> /// <param name="page"></param> /// <param name="url"></param> public static void NavigateParentToUrl(Page page, string url) { String script = @" try { var sUrl='" + url + @"'; if (self.parent.frames.length != 0) self.parent.location=sUrl; else self.location = sUrl; } catch (Exception) {} "; page.ClientScript.RegisterS... ......

Combining javascript files

I’ve read Combining Client Scripts into a Composite Script and wanted to use it. Then I’ve read Julian Jelfs concerns ScriptManager.CompositeScript issues However the article Combining javascript files with Ajax toolkit library describes workarounds, that make the solution workable. You also can use Script reference profiler: http://aspnet.codeplex.com/... Related posts: Using ScriptManager with other frameworks MSDN documentation: CompositeScriptReference The older implementations, ......

Implementations of HTML TidyLib for .Net

I was considering to add the HtmlValidator class to codeplex, but noticed that there are a few different implementations of HTML TidyLib for .Net. Not sure if any of them support my requirement to validate only structural errors, i.e. unmatched(not closed) open tags and unmatched(extra) close tags. But standard Tidy functionality will be good for most of users. 1. TidyManaged (https://github.com/markbea... Recent development (June 12, 2010), Positive reviews(e.g. here),Not much user ......

Validation of Html file

We’ve used HtmlAgilityPack based function IsValidHtmlFragment(string html) to validate dynamically loaded Html Fragments before inserting into main page(or do not insert if it is invalid) and recently noticed that it doesn’t return false for some fragments with not closed tags. I decided to find some other tool to call from the code and found that most of HTML parcers are too forgivven(like browsers) or too strict- to check full XHTML conformance. I am going to add manual procedure to run Tidy.EXE ......

Override ASP.NET Menu javascript functions to delay dynamic menus popup.

We are using asp.net Menu control and wanted to have some delay before sub-menu popup to avoid annoying popup, if user just move mouse through menu area. After some search on Google I found the solution submitted by yupinggang on the thread delaying the menu control. I've slightly modified it( put in a separate JS file,call initMenuMouseHoverInterceptors just in the same file,added handling of the case if no menu on the page etc.) Another possible solution- override PreRender in derived from Menu ......

Insert CSS link with updatable version number in URL

More than a year ago I wrote a post Code Render Blocks does not work inside HEAD server controls about the problem, that prevented me to update URL of CSS file, when version of assembly incremented. Now I've created a function /// <summary> /// /// </summary> /// <param name="page"></param> /// <param name="cssFileHref">e.g. "~/StyleSheet.css"</para... /// <returns></returns... public static HtmlLink AddStyleSheetLink(this Page page, string cssFileHref) ......

Display content of page in a modal dialog- consider jqModal.

I need to show popup info message with single close button, but content is located in separate html file. The current implementation using window.open not working for many users with popup blockers. My question is which tool/framework should I use. Initially I considered to use UFrame (see CodeProject article:UFrame: goodness of UpdatePanel and IFRAME combined )inside ASP.NET AJAX ModalPopup. Then I found question http://stackoverflow.com/qu... ......

CSS TD element style overrides Table class style.

I've created the MyTableClass CSS class(stored in .CSS file) and specified it to a HTML table. .MyTableClass { font-size: 8pt; } However the size of font inside the table was bigger than I specified. Thanks to VS 2008 CSS properties pane - Applied Rules section I was able to find that the rule was overridden by TD element style TD { font-size: 12px; } It was not hard to create hack to override global TD. .MyTableClass TD { font-size: 8pt; } I feel that having global element rule is not a good idea. ......

My Javascript Tips

Check if object is null or undefined. I had an understanding that to check if variable not null in JavaScrip, you need to check if (typeof SomeObject !='undefined') . But it is wrong, because null is not the same as 'undefined'. From http://weblogs.asp.net/bler... The shortest way to deal with this, and also the one that best expresses your intention of checking if an object is safe to use is probably to just rely on the ......

Set div to the vertical middle of the browser window

Our application shows custom HTML confirm message box, that we wanted to locate in the middle of the browser window. If I would start from the scratch, I would use Ajax Control Toolkit ModalPopup However, because the proprietary code to show div has been already written, I wanted just to set vertical position of the div. I've created a function based on code from AlwaysVisibleControlExtende... Initially it didn't work, because common.JS getClientBounds : function() returned 0 clientHeight and clientWidth. ......

Javascript variable declaration scope is different from C#.

It's well known that JavaScript is similar to C++/C#, but doesn't required explicit declaration of the variables. However, it worth to read specification(e.g. http://jennifermadden.com/j... ) to understand subtle differences. I didn't know, that a variable implicitly declared within a function is a global variable. For example, function foo() { g= 17;//it's global, will be visible outside the function after the function will be executed var x = 17;//local, not visible outside ......

Full CSS/DHTML/JavaScript Archive

«September»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011