My Blog
Welcome to my blog.
The articles will be related to programing and mostly to my domains of work: .NET, ASP.NET, MS SQL, AJAX, JavaScript etc.
Hope it helps. See you around.
-
XML Providers 4.0beta under Tiny Providers released
Today I released XML Providers 4.0beta under Tiny Membership Providers project.
Custom ASP.NET XML membership providers targeting .NET 4.0
The implementation ASP.NET XML membership providers targeting .NET 2.0 could be found at ASP.NET XmlProviders
I start with version 4.0 by purpose.
The versions bellow 4.0 are kept for future releases of .NET 2.0 implementation of ASP.NET XML membership providers.For how to use samples, please, check out the SampleWebSite under downloads.
Some more samples and screencast will be provided as possible. -
Extension Methods: HtmlTextWriter part 1 - RenderTag
So, for me case is clear guys: “Static helper methods are dead, long live the Extension Methods.”
Since extension methods were out, I become a big fan of them.
For example, instead of:StringHelper.Encode(“Some secret”);
it looks much more nice and natural to me:
”Some secret”.Encode();
I have implemented and I’m using tons of extension methods so far and I decided to start a category in my blog where to share some of them with you guys.
Hope all those methods to be useful to you too, as they are to me.First of the series will be a couple of extension methods to HtmlTextWriter.
You know, as a web and especially web controls developer, I use it much and that’s why I like extending it.During my development I found a lot of lines where I just render and open tag and then immediately the closing (end) tag is rendered, like:
writer.AddAttribute(HtmlTextWriterAttribute.Id, fieldName + "_Error");writer.AddAttribute(HtmlTextWriterAttribute.Class, "field-validation-error");writer.RenderBeginTag(HtmlTextWriterTag.Span);
writer.RenderEndTag();
The other case I often found myself using is: open tag, write some content text and closing the tag, like:
writer.RenderBeginTag(HtmlTextWriterTag.Span);
writer.Write("allow editing");writer.RenderEndTag();
I have developed some snippets for Visual Studio, which you could find at my website, in order to speed up typing such a kind of code bocks, but at some point I said to myself: why not merge those lines in a single methods. Of course, in a single extension method
.Here are the simple extension methods I came with:
/// <summary>/// Renders the tag./// </summary>/// <param name="writer">The writer.</param>/// <param name="tag">The tag.</param>public static void RenderTag(this HtmlTextWriter writer, HtmlTextWriterTag tag) {
writer.RenderBeginTag(tag);
writer.RenderEndTag();
}
/// <summary>/// Renders the tag./// </summary>/// <param name="writer">The writer.</param>/// <param name="tag">The tag.</param>public static void RenderTag(this HtmlTextWriter writer, string tag) {
writer.RenderBeginTag(tag);
writer.RenderEndTag();
}
/// <summary>/// Renders the tag./// </summary>/// <param name="writer">The writer.</param>/// <param name="tag">The tag.</param>/// <param name="content">The content.</param>public static void RenderTag(this HtmlTextWriter writer, HtmlTextWriterTag tag, string content) {
writer.RenderBeginTag(tag);
writer.Write(content);
writer.RenderEndTag();
}
/// <summary>/// Renders the tag./// </summary>/// <param name="writer">The writer.</param>/// <param name="tag">The tag.</param>/// <param name="content">The content.</param>public static void RenderTag(this HtmlTextWriter writer, string tag, string content) {
writer.RenderBeginTag(tag);
writer.Write(content);
writer.RenderEndTag();
}
Now using those extension methods the sample lines of code above will become:
writer.AddAttribute(HtmlTextWriterAttribute.Id, fieldName + "_Error");writer.AddAttribute(HtmlTextWriterAttribute.Class, "field-validation-error");writer.RenderTag(HtmlTextWriterTag.Span);
and:
writer.RenderTag(HtmlTextWriterTag.Span, "allow editing");
Hope this helps.Regards,
Velio -
Google Geocoder 1.0
Google Geocoding Web Service via HTTP .NET client implemented in request(GeoRequest)-response(GeoResponse) fashion.
Installation & Usage
In order to use the GoogleGecoding you have to:
- add reference to Artem.GoogleGeocoding
- add using statement for Artem.Google.Net namespace.
Features
- Support standard and reverse geocoding;
Samples
- Geocoding Request
GeoRequest request = new GeoRequest("plovdiv bulgaria");
GeoResponse response = request.GetResponse();
GeoLocation location = response.Results[0].Geometry.Location;
double latitude = location.Latitude;double longitude = location.Longitude;// TODO use latitude/longitude values
- Reverse Geocoding Request
GeoRequest request = new GeoRequest(42.1438409, 24.7495615);GeoResponse response = request.GetResponse();
string address = response.Results[0].FormattedAddress;// TODO use address values -
VisualStudion 2010 Javascript Outlining 1.2
A support for CSS content type was added in order to use outlining in CSS files, as well.
Features
- Outlines CSS codeblock regions for the code placed between { }. The closing brace is places on a new line and there is not another opeing brace on same line.
- Outlines custom regions defined by:
- /#region/ - /#endregion/
- /#>/ - /#</
Samples
- code block
body {background-color: #AAA;
font-family: Verdana;
font-size: 11px;
}
- long custom region definition
/*#region Test */body {background-color: #AAA;
font-family: Verdana;
font-size: 11px;
}
h1, h2, h3, h4 {
color: #5377A9;
font-family: Tahoma;
}
/*#endregion*/- short custom region definition
/*#> Test */body {background-color: #AAA;
font-family: Verdana;
font-size: 11px;
}
h1, h2, h3, h4 {
color: #5377A9;
font-family: Tahoma;
}
/*#<*/ -
VisualStudion 2010 Javascript Outlining 1.0
As a Web 2 developer I found myself dealing with fast growing JavaScript code files.
And I really missed the code regions in Visual Studio, which is a nice way to organize the code blocks and focus on reasonable small amount of code.
There are some macros available out on the web for placing a regions outlining in JavaScript code editor.
I was not fully satisfied with macros and the fact I have to manually run them (even with a shortcut keys) every time I open the JavaScript file.
Thus, I have spend some amount of my time and came out with a Visual Studio 2010 Editor Extension for JavaScript Oulining.
Even, if this first version is simple as functionality it gave me much better JavaScript code experience.
So, I decided to share it with you guys and hope it helps you too.Please, find the visual studio package here
Enjoy -
“Fixing” Visual Studio 2010 HTML snippets
Visual Studio 2010 is out now.
It is great the new Visual Studio 2010 allow usage of code snippets widely now.
Apart of that, the cursor is goes at wrong place after inserting some of the HTML snippets, which breaks the nice continuous typing experienceHave same problem like me?
Do you know you can edit and "fix" them.Check out this short video, where I for example change the standard textbox snippet
Hope this helps,
Regards -
GoogleMap Control using MarkerManager video
Hi, I have published a new short “HowTo” video about how to use MarkerManager with GoogleMap Control 4.1.
Check it out here.The background music is a track of the new upcoming album of my friend Svetlin Staykov – Slow Project.
I hope you enjoy both, video and music.Regards
-
GoogleMap Control 4.1 beta released
I just released GoogleMap Control 4.1 beta.
Get it from codeplex, and give it a try.Release Notes
In this release were fixed some important issues like: large number of markers using geocoding, zoom end event cycling etc.
Some new features were implemented as well, check out the list below.
I would like to highlight the proper implementation of Marker Manager coming in this release.
Check out the list of changes connected with that feature below.Issues
- Large number of markers using geocoding
- ZoomEnd event subscribing problems
Features
- MarkerManager - MarkerManager is used to manage visibility of hundreds of markers on a map, based on the map's current viewport and zoom level.
- The GoogleMaps API GMarkerManager class is deprecated and I have used the recommended open sourced MarkerManager instead.
- I have added a new inner property MarkerManagerOptions in order to manager the options for the marker manager.
- GoogleMarker class was changed and couple of new properties were added to it to: MaxZoom and MinZoom.
- A sample page was added to Samples Website under /marker/MarkerManager.aspx. Check the sample page online here
- Check out the short demo video (coming soon)
- Map
- Directions
- Polygon
Changes
- The Anonymous JS classes' functions were changed to Pseudo-Named functions for better JS debug and error feedback experience.
- Samples Websites for .NET 2.0 and VB were removed - Sorry, guys, I just have no enough time to support and keep them up to date.
Regards
-
JS Pseudo-Named functions
I’m working recently on next release of GoogleMap Control v4.1.
As I have mentioned - I’m switching from anonymous to pseudo-named JS function for that release.
All the effort made, was for a better JS debug and error feedback experience.At least, that’s the theory.
However, today I did some work on the control again and had a chance in practice to prove I was right.
I got some JS error during my work, but the information I have now in the call stack is much more useful than just a list of anonymous function.Here is a simple example of what I mean:
In this particular case, I just mismatch the functions’ bodies, but you get the idea, right.
Regards
-
Generic extension method for a safe item value fetch from HttpSessionState.
Hi there,
Here is an extension method for getting a value from the session in a safe manner.
1: static public bool TryGet<T>(this HttpSessionState session, string key, out T value) {
2:3: bool flag = false;
4: value = default(T);
5:6: if (session != null) {
7: object objectValue = session[key];
8: if (flag = (objectValue != null && objectValue is T)) value = (T)objectValue;
9: }10:11: return flag;
12: }The usage is simple like:
1: bool flag;
2: if(this.Page.Session.TryGet<bool>("MyFlag", out flag)) {
3: // TODO value exists and can be used
4: }Regards