Wednesday, November 26, 2008

Replace NewLine in TSQL

It's quite frustrating how tiny task become so time-consuming and worrisome. Never would have imagined this hard to do. 

Had a situation where records gathered from an application will serve as input to a large application. The data first had to be cleaned (glad I got Sql server tools). This was done in seconds. On export to CSV, it was discovered that one of the fields (address field) had newline inputed in it causing wraping of the record as new line in the exported CSV.

Of course I was quick to type

update xxxxx set CustAddress = Replace(CustAddress, char(13), '')

Alas, no change. Kept getting same reponse. Even len(CustAddress ) = Replace(CustAddress, char(13), ''). 

Search for this issue on the net and could not find a direct linking article of blog reporting this scenerio. 

I finally got the answer from an article on Simple-talk by Robyn Page and Phil Factor

update xxxx set custaddress = REPLACE(custaddress, COALESCE(char(13) + char(10),'[^-a-z'']'), '')

Quite some other stunt in the article too.

Friday, November 21, 2008

MSFT's Application Architecture Guide 2.0 Beta 2

Microsoft Patterns & Practice team has recently released the beta 2 of the Application Architecture Guide 2.0 offering significant changes from Beta 1 among which are

Technology matrixes for choosing technologies like Presentation, Data Access, Workflow, and Integration technologies. 
New Agile Architecture Method 
Tuned and pruned the recommendations across the entire guide. 
Restructured the guide for simpler parts 


Read more about the changes at J.D. Meier's blog

Thursday, November 20, 2008

Microsoft Expression Web Inline Styles

I like to agree that Microsoft Expression Web is a great tool to use. I instantly saw the need to need for such tool to complement Visual Studio and considering that it's has less memory footprint tool and I can get my tortoise- performing notebook (Never seem to get a machine fast enough -HP Compaq nc6400)  to deliver working on a web page faster.  It is also very cool with css and I consider tracing image very "slick". 

I am particularly irritated with the fact that the designer generates only inline-styles. I experienced this with silence in version 1 and this persisted in version 2. Even if the element being moved around in the designer already has a class attribute, one notices that an inline style is created for the element and have to manually copy and merge the changes with what is the external style.

Is there a mode like this in this because I really cannot imagine the designer of this tool missing out on this kind of cool feature.

Wednesday, November 19, 2008

ASP.Net Textbox watermark

I don't like to do javascript! Asked myself several times over the past years why my javascript has been so poor even it has several syntax semblance to C# and other languages with same cancer of the semi-colons ;).

What I have been able to identify a reason for dislike is the poor IDE support for javascript. Visual Studio brought quite a bit of cool supports and features but not enough for an aging brain like mine to pick up. However, rising to the challenge and had to do a textbox watermark. 

I had done this before with a sample from Stan (a friend - Great Chap) but can't seem to find the source anymore nor Stan himself and also done this with ASP.Net Ajax but the client do not want Ajax feature, nor is ready to pay more for that so I had to revert to my plain-old javascript in ASP.Net and this is what I came up with.


App_Code
public static void WatermarkHelper(TextBox textBox, bool isPostBack, string defaultText)
    {
        textBox.Attributes.Add("onfocus", isPostBack ? "" : "WatermarkFocus(this, '" + defaultText + "');");
        textBox.Attributes.Add("onblur", isPostBack ? "" : "WatermarkBlur(this, '" + defaultText + "');");

        textBox.Attributes.Add("class", isPostBack ? "normal" : "watermark");
        textBox.Text = defaultText;
    }

Page_Load
Util.WatermarkHelper(plsperacreText, IsPostBack, "Enter Code");

Javascript
function WatermarkFocus(element, defaultText) {

            if (element.value == defaultText) {
                element.className = "normal";
                element.value = "";
            }
        }

        function WatermarkBlur(element, defaultText) {
           

            if (element.value == defaultText || element.value.length == 0) {
                element.className = "watermark";
                element.value = defaultText;
            }
            else
                element.className = "normal";
        }


CSS
.watermark
{  
/* sure u can add a lot more */
   color: DarkGray;
}

.normal
{
}


And that does it

Monday, November 17, 2008

e-Commerce Development

I really do not like to do websites. In fact, I used to hate to do one and though I develop quite a bit of web-based business applications with C# and ASP.Net, website development seems not what I'd like to do.

Recently, I had to take a full e-Commerce website using ZNode and LinkPoint payment gateway from First Data. ZNode is pretty interesting and intend to do a service site using this. I did not particularly like Linkpoint. The documentaion on it's setup and integration to applications is quite lame and I waste quite a bit of time trying to figute it out.

This has prevented me from the scheduled task for this week of revving the PDC 2008 conference content. 

Wednesday, November 12, 2008

PDC 2008



Just returning back to serious work after PDC 2008 at Los Angeles. Had lots of fun with co-developers. The technology show-cased were cool and got new insights too. My utmost interest is with Azure. I am yet to start drilling through my 160GB hard disk given to us but will do soon and pump lots more content about my accomplishments here. Hang on ...



Check out more pix of the event at PDC 2008

Back to Blogging here

I guess I will have to return to blogging here. Inthril that host my blog for a while has been having problems and so I could not log in.

It's been a while I blogged. Been clogged down with lots of task and thinking and having done a lot. I Need to showcase quite a bit ot what's going on in my head.