November 2008 - Posts
Well,
I was looking on the web for JavaScript fuction that return any DOM element position and also consider browser scroll.
I finally came up with the solution and wanted to share it with you.
In order that the script will work you need reference to Prototype JavaScript Framework.
Well here is the JavaScript code:
function getDocumentWindow(doc) { return (doc.parentWindow || doc.defaultView);
}
function getPosRelativeToWindow(element, topWindow, considerScrollOffset) { var l = 0, t = 0; var pos, doc, w, lastWindow;
topWindow = topWindow || top;
while (element) {
doc = element.ownerDocument;
w = this.getDocumentWindow(doc);
lastWindow = (!w || w == topWindow);
if (lastWindow)
pos = Position.cumulativeOffset(element);
else
pos = Position.page(element);
if (considerScrollOffset) { var p = Position.realOffset(element);
l -= p[0];
t -= p[1];
}
l += pos[0];
t += pos[1];
if (lastWindow) break;
element = w.frameElement;
}
return [l, t];
}
Cheers,
Rotem
Regular expressions are much easier to understand if you use the following syntax and comment each component of the expression by using a number sign (#). To enable comments, you must also specify RegexOptions.IgnorePatternWhitespace, which means that non-escaped white space is ignored.
Regex regex = new Regex(@"
^ # anchor at the start
(?=.*\d) # must contain at least one numeric character
(?=.*[a-z]) # must contain one lowercase character
(?=.*[A-Z]) # must contain one uppercase character
.{8,10} # From 8 to 10 characters in length
\s # allows a space
$ # anchor at the end",
RegexOptions.IgnorePatternWhitespace);
Enjoy,
Rotem
Hi,
Today I wrote Silverlight presentation in order to introduce Silverlight technology to our Product and R&D department.
The presentation covers:
Some of the slids taken from Alex Golesh presentation, when he was lecture on Silverlight 2 for Ness Tsioyna User Group (BTW - it was great lecture). I add some more slids and screen shoots of my own.
You can download the presentation from here.
Hi,
I decided to take a look and play with MS "Velocity" Distributed Caching. “Velocity” is a distributed in-memory application cache platform for developing scalable, available, and high-performance applications. “Velocity” fuses memory across multiple computers to give a single unified cache view to applications. Applications can store any serializable CLR object without worrying about where the object gets stored.
Well I download the latest version CTP2 install it on 2 computers and it works very nice. Velocity supports the common cache types: partitioned cache, replicated cache and local cache. Depending on the type of data, applications can choose the appropriate type of cache.
On this version there are: Performance improvements, PowerShell integration, Additional Configuration Store options and native 64 bit support. Of course there is the ASP.NET Session State Provider that is very cool feature.
Presentations and Videos: "Velocity": A First Look, "Velocity": Under the Hood
You can read a lot more here.
Hi All,
One of the main rule in order to improve your aspx page load time, is to reduce its page size.
One of the recommendation is to use *js files and compress them and save them to one js file on production.
Well Douglas Crockford wrote JSMin in C# for the .NET users.
JSMin - is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation.
You can download JSMin C# version from here.
In order to check that the js file is valid after JSMin it is suggested that JSLint be used before using JSMin.
Hi All,
Bertrand Le Roy that is Program Manager in charge of AJAX at Microsoft wrote a nice article on the future of ASP.NET AJAX.
The article discusses:
-
Server-side data manipulation
-
UpdatePanel and the client
-
Reducing postbacks and payloads
-
Client-side template rendering
The article also cover some new feature like: support on back button, New render engine for ajax.
You can found the article here.
Hi All,
You can mapped any .NET types that found on one assembly to other type that found on second assembly using the tagMapping element on the web.config.
On the example below I show how can you mapped the .NET validators types, found on System.Web.dll to your own custom assembly named "Validators.dll".
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Sample.Web.UI.Compatibility.CompareValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Sample.Web.UI.Compatibility.CustomValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Sample.Web.UI.Compatibility.RangeValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Sample.Web.UI.Compatibility.RegularExpressionValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Sample.Web.UI.Compatibility.RequiredFieldValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Sample.Web.UI.Compatibility.ValidationSummary, Validators, Version=1.0.0.0"/>
</tagMapping>