Tuesday, April 04, 2006
Thursday, October 27, 2005
Append client event
if(txtDealerPercent.Attributes["onblur"]!=null && txtDealerPercent.Attributes["onblur"].Length>0)
sb.Append(txtDealerPercent.Attributes["onblur"]);
sb.Length = 0;
sb.Append("otherdealerfee_onblur('");
sb.Append(this.txtDealerAmount.ClientID);
sb.Append("','");
sb.Append(this.txtDealerPercent.ClientID);
sb.Append("','percent');");
txtDealerPercent.Attributes.Add("onblur", sb.ToString());
WordClean
text=text.replace(/]*>/gi,""); ]*>/gi,"¶g"); ");
text=text.replace(/<\/FONT>/gi,"");
text=text.replace(/
text=text.replace(/<\/H[^>]*>/gi,"");
// Change these tags.
text=text.replace(/]*>/gi,"&bold");
text=text.replace(/<\/B[^>]*>/gi,"&cbold");
text=text.replace(//gi,"&under");
text=text.replace(/<\/U>/gi,"&cunder");
text=text.replace(/]*>/gi,"&bold");
text=text.replace(/<\/STRONG[^>]*>/gi,"&cbold");
text=text.replace(/]*>/gi,"&ital");
text=text.replace(/<\/I[^>]*>/gi,"&cital");
text=text.replace(/]*>/gi,"&ital");
text=text.replace(/<\/EM[^>]*>/gi,"&cital");
text=text.replace(/]*>/gi,"&ultag");
text=text.replace(/
text=text.replace(/]*>/gi,"&oltag");
text=text.replace(/<\/OL>/gi,"&olctag");
text=text.replace(/<\/LI>/gi,"&lictag");
text=text.replace(/<\/UL>/gi,"&ulctag");
text=text.replace(/
text=text.replace(/<\/P>/gi,"&cparag");
text=text.replace(/<[^>]>*;/gi,"");
text=text.replace(/<\/[^>]>*;/gi," ");
text=text.replace(/
text=text.replace(/<\/o:[^>]*>/gi,"");
text=text.replace(/<\?xml:[^>]*>/gi,"");
text=text.replace(/<\/?st[^>]*>/gi,"");
text=text.replace(/<[^>]*]*>/gi,"");
text=text.replace(//gi,"");
text=text.replace(/<\/SPAN>/gi,"");
//text=text.replace(/<\/A>/gi,"");
// Clear the inner parts of other tags.
text=text.replace(/style=[^>]*"/g,' ');
text=text.replace(/style=[^>]*'/g," ");
text=text.replace(/style=[^>]*>/g,">");
text=text.replace(/lang=[^>]*>/g,">");
text=text.replace(/name=[^>]* /g,"");
text=text.replace(/name=[^>]*>/g,">");
text=text.replace(/]*>/g,"");
// Put the tags back
text=text.replace(/&bold/g,"");
text=text.replace(/&cbold/g,"");
text=text.replace(/&under/g,"");
text=text.replace(/&cunder/g,"");
text=text.replace(/&ital/g,"");
text=text.replace(/&cital/g,"");
text=text.replace(/&ultag/g," ");
text=text.replace(/&litag/g,"
text=text.replace(/&oltag/g," ");
text=text.replace(/&olctag/g,"<\/OL>");
text=text.replace(/&lictag/g,"<\/LI>");
text=text.replace(/&ulctag/g,"<\/UL>");
text=text.replace(/¶g/g,"
text=text.replace(/&cparag/g,"
Friday, July 29, 2005
Tuesday, June 07, 2005
Five Great Patterns for Dealing with References
Five Great Patterns for Dealing with References
Descriptor Pattern
The descriptor pattern, mixes best practices from the previous two patterns. Basically, a descriptor is a collection of instances of the class itself. Using this pattern, the CourseLevels class can be implemented as follows.
public class CourseLevels
{
public static CourseLevels Beginner = new CourseLevels();
public static CourseLevels Advanced = new CourseLevels();
public static CourseLevels VeryHigh = new CourseLevels();
public static CourseLevels Expert = new CourseLevels();
}
Because the instances are again static, descriptors are type safe, both in simple checks as in operation signatures, just like enumerations, as the following example shows.
if (MyCourse.Level == CourseLevels.Beginner) { … }
Methods on the Course class can also be specified elegantly.
public bool HasLevel(CourseLevels level)
{
return (Level == level);
}
Also descriptors can be extended, like constant collections. In the simple implementation above however, it is not possible to use display values other than the defined names of the instances. Luckily a straightforward extension to this implementation solves these issues, if necessary.
public class CourseLevels
{
public string DisplayValue;
public CourseLevels(string displayvalue)
{
DisplayValue = display;
}
public static CourseLevels Beginner = new CourseLevels("Beginner");
public static CourseLevels Advanced = new CourseLevels("Advanced");
public static CourseLevels VeryHigh = new CourseLevels("Very high");
public static CourseLevels Expert = new CourseLevels("Expert");
}
Still, descriptors have a fixed number of elements, just like enumerations and constant collections. And again, like the latter, retrieving the set of possible values requires reflection. In C#, in both patterns, an operation like the following takes care of this job.
public static CourseLevels[] GetValues()
{
ArrayList list = new ArrayList();
foreach (FieldInfo pi in type.GetFields())
{
list.Add((CourseLevels) pi.GetValue(type));
}
return (CourseLevels[]) list.ToArray(typeof(CourseLevels));
}
Wednesday, March 16, 2005
How To Convert Strings to Title (Proper) Case using C#
How To Convert Strings to Lower, Upper, or Title (Proper) Case by Using Visual C# .NET: "textInfo.ToTitleCase(title));"
Thursday, February 17, 2005
Thursday, February 10, 2005
CustomValidator dependent on multiple controls. - ASP.NET
The Code Project - CustomValidator dependent on multiple controls. - ASP.NET: " ValidatorHookupControlID('<%= Phone.ClientID %>', document.all['<%= AtLeastOneContact.ClientID %>']);
ValidatorHookupControlID('<%= Email.ClientID %>', document.all['<%= AtLeastOneContact.ClientID %>']);"
