Be aware always to use overloaded methods of ToLower/ToUpper of System.String class that accepts CultureInfo instance, if you don't want your application to fail in some circumstances when a user regional setting differs from English. In my case I had bug for users with Turkish regional settings, because uppercase "I" lowered to "ı" but not "i" as was expected. The only case when you might use overload with no parameters of ToLower/ToUpper methods is when you need to display lowered or uppercased strings onto UI. Thanks to ToLowerInvariant/ToUpperInvariant in .NET 2.0, but not worked for me, my app requires running under .NET 1.1.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

When you use RadioButton control inside templated data bound control i.e. GridView, Repeater, and RadioButton's GroupName property is set because you want radio buttons to be mutually exclusive you may notice that actualy radio buttons aren't mutually exclusive, see kb article this also applies to .net framework  2.0/3.5. As a workaround for this issue I've implemented Ajax Control Extender. I hope this will be useful.

Client Side Behavior:
[code:js] /// /// /// /// Type.registerNamespace('RadioGroupExtender'); RadioGroupExtender.RadioGroupBehavior = function(element) { RadioGroupExtender.RadioGroupBehavior.initializeBase(this, [element]); // this._groupName = null; this._clickDelegate = null; } RadioGroupExtender.RadioGroupBehavior.Groups = new Array(); RadioGroupExtender.RadioGroupBehavior.prototype = { initialize : function() { RadioGroupExtender.RadioGroupBehavior.callBaseMethod(this, 'initialize'); var containsGroup = false; for(i = 0;i < RadioGroupExtender.RadioGroupBehavior.Groups.length;i++){ if(RadioGroupExtender.RadioGroupBehavior.Groups[i].groupName == this._groupName){ containsGroup = true; break; } } if(!containsGroup){ Array.add(RadioGroupExtender.RadioGroupBehavior.Groups, { groupName: this._groupName, elements: new Array() }); } Sys.Debug.trace(RadioGroupExtender.RadioGroupBehavior.Groups.length); for(i = 0;i < RadioGroupExtender.RadioGroupBehavior.Groups.length;i++){ if(RadioGroupExtender.RadioGroupBehavior.Groups[i].groupName == this._groupName) { if(!Array.contains(RadioGroupExtender.RadioGroupBehavior.Groups[i].elements, this)) { Array.add(RadioGroupExtender.RadioGroupBehavior.Groups[i].elements, this); } break; } } var element = this.get_element(); if (this._clickDelegate === null) { this._clickDelegate = Function.createDelegate(this, this._clickHandler); } Sys.UI.DomEvent.addHandler(element, 'click', this._clickDelegate); }, dispose : function() { var element = this.get_element(); if (this._clickDelegate) { Sys.UI.DomEvent.removeHandler(element, 'click', this._clickDelegate); delete this._clickDelegate; } RadioGroupExtender.RadioGroupBehavior.callBaseMethod(this, 'dispose'); }, get_GroupName : function() { return this._groupName; }, set_GroupName : function(value) { this._groupName = value; }, add_click: function(handler) { this.get_events().addHandler('click', handler); }, remove_click: function(handler) { this.get_events().removeHandler('click', handler); }, _clickHandler : function(event){ for(i = 0;i < RadioGroupExtender.RadioGroupBehavior.Groups.length;i++){ if(RadioGroupExtender.RadioGroupBehavior.Groups[i].groupName == this._groupName){ for(j = 0;j < RadioGroupExtender.RadioGroupBehavior.Groups[i].elements.length;j++){ var elm = RadioGroupExtender.RadioGroupBehavior.Groups[i].elements[j].get_element(); elm.checked = false; } break; } } var element = this.get_element(); element.checked = true; var h = this.get_events().getHandler('click'); if (h) h(this, Sys.EventArgs.Empty); } } RadioGroupExtender.RadioGroupBehavior.registerClass( 'RadioGroupExtender.RadioGroupBehavior', AjaxControlToolkit.BehaviorBase); [/code]
Extender Server Control:
[code:c#] using System; using System.Web.UI.WebControls; using System.Web.UI; using System.ComponentModel; using System.ComponentModel.Design; using AjaxControlToolkit; [assembly: System.Web.UI.WebResource("RadioGroupExtender.RadioGroupBehavior.js", "text/javascript")] namespace RadioGroupExtender { [Designer(typeof(RadioGroupDesigner))] [ClientScriptResource("RadioGroupExtender.RadioGroupBehavior", "RadioGroupExtender.RadioGroupBehavior.js")] [TargetControlType(typeof(RadioButton))] public class RadioGroupExtender : ExtenderControlBase { [ExtenderControlProperty] [DefaultValue("")] public string GroupName { get { return GetPropertyValue("GroupName", ""); } set { SetPropertyValue("GroupName", value); } } } } [/code]
If you having problems using code, download source code here.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Website Screenshots

Published 1/22/2008 by .Gicu in .NET

I heard from many colleagues something like: Can be HTML output rendered as image, and obtained image will look like HTML presentation in web browser? There are many web sites that do this like http://www.webshotspro.com/. But another solution and probably best is to use System.Windows.Forms.WebBrowser that internally uses IE Browser Engine.

The following sample code demonstrates how to use IE Browser Engine in console application to obtain web site screenshots.

[code:c#] using System; using System.Collections.Generic; using System.Text; // using System.Windows.Forms; using System.Drawing; using System.Drawing.Imaging; using System.Diagnostics; using System.Drawing.Drawing2D; namespace WebScreenShot { class Program { // Important IE Web Browser ActiveX can't run in Multi Threaded Apartment(MTA), // in ASP.NET page set AspCompat attribute to True. [STAThread] static void Main(string[] args) { string url; int with, height, s_width, s_height; string fileName = string.Format(@"d:\webscreenshot_{0}.bmp", DateTime.Now.Ticks); Console.Write("Enter URL:"); url = Console.ReadLine(); Console.Write("Enter Width:"); with = Convert.ToInt32(Console.ReadLine().Trim()); Console.Write("Enter Height:"); height = Convert.ToInt32(Console.ReadLine().Trim()); Console.Write("Enter Screen Width:"); s_width = Convert.ToInt32(Console.ReadLine().Trim()); Console.Write("Enter Screen Height:"); s_height = Convert.ToInt32(Console.ReadLine().Trim()); using (WebBrowser wb = new WebBrowser()) { wb.Width = s_width; wb.Height = s_height; wb.ScrollBarsEnabled = false; wb.Navigate(url); while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } using (Bitmap bmpScreen = new Bitmap(s_width, s_height)) { // DrawToBitmap is not supported but stil works :) wb.DrawToBitmap(bmpScreen, new Rectangle(0, 0, s_width, s_height)); using (Bitmap bmp = new Bitmap(with, height, bmpScreen.PixelFormat)) { using (Graphics g = Graphics.FromImage(bmp)) { g.CompositingQuality = CompositingQuality.HighQuality; g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBilinear; g.DrawImage(bmpScreen, new Rectangle(0, 0, with, height)); bmp.Save(fileName, ImageFormat.Bmp /*bmp for quality*/); } } } } Process.Start(fileName); Console.ReadKey(); } } } [/code]

Note: code requires to add reference to System.Windows.Forms.dll & System.Drawing.dll assemblies.

Example screenshot:

Example screenshot

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

What is .NET?

Published 11/12/2007 by .Gicu in .NET

Many developers work with .NET, and if you ask a developer what is .NET you would probably hear the worst answer. I think it is important for developer to know what is .NET in fact. As discribed by Microsoft, .NET is the Microsoft Web services strategy to connect information, people, systems, and devices through software.

See http://www.microsoft.com/net/basics.mspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

My First Blog Entry

Published 11/12/2007 by .Gicu

I've been very impressed how easy is to setup BlogEngine.NET, it's look great!

Thx to Mads Kristensen!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

.Gicu's Blog

Gheorghe Bulicanu's blog, programming, .net ...