Skip to main content

Posts

Showing posts from 2009

JavaScript confirmation disables validation

I had to do a JavaScript confirmation before I perform the post back on a web form. What I have done is just call button.attributes.add("onClick", -- ) and added the confirmation. It worked fine and showed the popup and did the post back if I clicked on the OK button. But if I have implemented some validations on the fields they doesn't fire them if the validation fails. For example if there is a required field validator the post back happens even without the values for that required field. what I want is to do the validation and then do the post back. Luckily I've found a solution at http://forums.asp.net/t/963412.aspx?PageIndex=1 by sukdeb . function Validate() {     var yes=confirm("Update this application?");     if(yes)     {         Page_ClientValidate();         return Page_IsValid;     } return false; } <asp:button runat="server" text="Button" onc...

Sort Fields which contains both Numeric and Characters

It was a long time since my last post. Finally I got something to write about. Store Procedures … something I hate most of the time. But today I felt good about them because I was able to find a solution for a sorting issue. The particular column contained data like “98ABC-76543-DEF-12345-GHI 10 ” and also “GHJ 23 ”. I was supposed to sort this field on Numeric value for the last part in red . And for the other parts it should be treated as Numeric for the Numeric parts and as Strings for the others. So what should I do was to split all parts and sort them separately and get numeric part in red and sort. But wait a minute do we have to all the things??? I don’t think so... I have found ( actually one of my friends ) an easy way to do that. Here it is. SELECT [name], RANK() OVER (ORDER BY CAST(PARSENAME(modifiedName, 5) AS nvarchar ), CAST(PARSENAME(modifiedName, 4) AS INT ), CAST...