Skip to main content

Posts

Clear Validation Errors and Validation Summary messages

ASP.net built in validation does not provide us a straight forward to clear all the validation errors. This would be really helpful while resetting a form. The reset html button would simply reset the form values but will not clear the validation errors. The following javascript code snippet can be used to clear the validation error messages. Have a reset button on your form and call the following js function onclick. <input type="reset" onclick="HideValidationErrors();" /> function HideValidationErrors() { //Hide all validation errors if (window.Page_Validators) for (var vI = 0; vI < Page_Validators.length; vI++) { var vValidator = Page_Validators[vI]; vValidator.isvalid = true; ValidatorUpdateDisplay(vValidator); } //Hide all validaiton summaries if (typeof (Page_ValidationSummaries) != "undefined") { //hide the validation summaries ...

PostBack the form when a value is selected from the results returned by autocomplete extender

Some times we would like to do a post back when we select a value from the results returned by the Autocomplete extender. To do this you can leverage one of the client side properties that the AutoComplete Extender exposes. The property is OnClientItemSelected which takes a javascript method name as value. <asp:UpdatePanel runat="server" id="UpdatePanel1" > <asp:TextBox ID="txtOrderNumber" runat="server" AutoCompleteType="Disabled" MaxLength="5"></asp:TextBox> <ajaxToolkit:AutoCompleteExtender ID="OrderNumberAutoCompleteExtender" runat="server" CompletionInterval="100" CompletionSetCount="20" EnableCaching="true" MinimumPrefixLength="2" ServiceMethod="GetOrderList" ServicePath="~/ASPX/Common/AutoComplete.asmx" TargetControlID="txtOrderNumber" OnClientItemSelect...

AutoComplete Extender dropping leading zeroes from the values in the result set

The autocomplete extender in the AJAX Control Toolkit drops off the leading zeroes from the values in the returned result set. This appears to be a known bug in the Autocomplete Extender. To rectify this problem, add single quotes to the value before adding it to the list either in your Web Method or Page Method that the AutoComplete Extender uses to load the results In your web method or page method do the following. resultList.Add("'"+result+"'"); //Single quotes are need as a work around for a known bug in autocomplete extender. Leading zeroes are dropped without quotes.

Check if a Child Window is closed using Javascript

The basic idea here is to have a javascript timer, that checks to see if the child window is closed. The setTimeout function in javascript takes a function as input and runs at a specified interval. In the function we give as input to the timer, we check to see if the popup window is closed, if closed do what ever you want to do if the popup is closed and stop the timer. <script language="javascript"> var detailsWindowTimer; var detailsWindow; function OpenDetailsWindow() { detailsWindow = window.open('../../UserDetails.aspx?UserID=1', ' 'UserDetails','directories=0,location=0,toolbar=0,status=1,menubar=0,scrollbars=1,resizable=1'); detailsWindow.focus(); detailsWindowTimer = setInterval("WatchDetailsWindowForClose()",2000); //Poll every 2 seconds to see if the details window is open or closed } function WatchDetailsWindowForClose() {...

Postback the updatepanel when an item is selected in AutoCompleteExtender

<asp:TextBox ID="txtOrderNumber" runat="server" AutoCompleteType="Disabled" MaxLength="5"></asp:TextBox> <ajaxToolkit:AutoCompleteExtender ID="OrderNumberAutoCompleteExtender" runat="server" CompletionInterval="100" CompletionSetCount="20" ContextKey="region" EnableCaching="true" MinimumPrefixLength="2" ServiceMethod="GetOrderNumberList" ServicePath ="~/ASPX/Common/AutoComplete.asmx" TargetControlID="txtOrderNumber" UseContextKey="true" OnClientItemSelected="OrderNumberChanged" />

How to use ASP.net AJAX timer control to alert user when session times out.

Recently I needed a way to redirect the user to the login page after a certain time of inactivity. I found a neat way to do this using ASP.net AJAX timer control. Following is the approach I took. I put the code in my master page as it can be shared by all the content pages. 1) Drag and drop the script manager control. 2) Drag and drop an update panel. 3) Set the updatepanel's UpdateMode property to Conditional . 4) Drag and drop a Timer control inside the update panel. Set the Interval property to the session time out time. 5) Set the timer control as a trigger to the update panel which causes it to postback on some event (Tick) . Following is the code after the first 5 steps. <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanelMaster" UpdateMode="Conditional" runat="server"> <ContentTemplate> <asp:T...

SharePoint: Comparing dates in XSLT

In one of my sharePoint projects, I had to compare a date with the current date in XSLT. As it turned out, there is no support for date comparision in XSLT. This is how I went about doing it. The trick involves converting the date string into a number Say the date is in ISO format YYYY-MM-DDTHH:MM:SSZ (for example, 2001-01-21T22:54:47Z). Say we have a variable DueDate <xsl:variable name="DueDate" select="'2001-01-21T22:54:47Z'"> Replace the dashes in the string with empty string Take the first 10 character in the date sring convert the string to number number(translate(substring(@DueDate,1,10),'-','')) On doing the above we get: 20010121 We can do the same thing with the date to compare. We can compare the duedate with the current date in SharePoint as follows number(translate(substring(@DueDate,1,10),'-','')) & lt; number(translate(substring(ddwrt:TodayIso(),1,10),'-','')) You can apply the same log...

Gandhigiri

Some of the Indians who were affected by the USCIS revised July bulletin staged a novel protest (Gandhigiri) by sending flowers to USCIS. Follow the links below for more details. http://www.ibnlive.com/news/immigrants-refused-green-cards-take-to-gandhigiri/44667-2.html?xml http://www.ibnlive.com/videos/44667/immigrants-refused-green-cards-take-to-gandhigiri.html

USCIS and the 485 Fiasco....

I hope by now most of the victims of July Visa bulletin have recovered. It is beyond any one's comprehension how USCIS could behave in such an irresponsbile manner. They had a freaking two weeks to issue a correction to the bulletin but they waited until they received the applications only to send them back. Forget about the expenses incurred during the 485 filing process, the long lines to get medical exams done and the time wasted to get all the paper work done, I heard stories of people cancelling their travel plans, returning from abroad, flying to the lawyers' offices to complete the forms etc. I wonder if USCIS deliberately rejected all the applications so that they could collect the hiked fee which increases 3 fold from August. After this stupid action I feel that the state department has no concern for immigrants' feelings.

Taste of Vista

I had a taste of Vista this weekend on my friend's laptop. I think Microsoft shot itself in the foot with their over protective security features. I'm pretty sure users will get exhausted with "Are you sure you.....? after some time. I dont understand why I have to confirm every time I open an application. Didn't M$ft think about how it will ruin the end user experience? My friend created a website in .Net and wanted to host it in IIS. To successfully host the website in IIS we had to go through a multi layered defense system. We overcame the first line of defense by turning on the IIS feature, which I think is good. Then came the second line of defense which is "No permissions to....." to which we did not have a straight answer. After spending some time on Google with no luck, we stumbled on the answer by chance. (We had to give IUSR account permissions on the physical directory that contains the website). I thought well this is the answer and tried to laun...

Parser Error Message: Access is denied

Some times while debugging a web application in Visual Studio, I run into error similar to the one below. The error does not go away even when Aspnet_wp.exe process is killed and IIS restarted. Parser Error Message: Access is denied It happens that the error message occurs when the Microsoft Index Server (Cisvc.exe) is running on your machine. Cisvc.exe holds a lock on the Temporary ASP.NET Files directory. For a quick fix, kill the Cisvc.exe. For a permanent fix exclude the temporary ASP.NET files directory from being indexed by the index server. More on the error can be found at MSDN .

Inida face early exit from the world cup

I was a bit down yesterday as India lost against Sri Lanka and are almost out of the world cup. But on putting the defeat in proper perspective, I realised that the Indian team is a bad team and bad teams are supposed to lose. It is immature to get emotional when a bad team loses. Now that India will not be playing any more, I can relax and just enjoy the game of cricket. That is what I'm doing right now. I'm watching South Africa chase Australia's mammoth total of 377 with great ease.

Getting Started with ASP.NET AJAX

I have been doing AJAX in ASP.NET for a while using frameworks like Anthem.Net and AJAX.net. I did not use Atlas as Atlas was still in development and more over our client has not upgraded to .Net 2.0 yet. I have started playing with Microsoft ASP.NET AJAX (formerly Atlas) for a week now. At first I was really overwhelmed with the whole Atlas documentation but felt a little comfortable after watching the Ajax videos on ASP.NET website . Here I will go through the process of getting started with Microsoft ASP.NET AJAX. You can access this post here on Google docs. http://docs.google.com/View?docid=dd8p9vd3_7dzckx7 Install MS AJAX Download and install Atlas from here.( http://ajax.asp.net/downloads/default.aspx?tabid=47 ) Visual Studio Tool Box After installing MS AJAX, you should see AJAX Extensions tab in the visual studio tool box. New ASP.NET project template A new project template that allows you to create ASP.NET AJAX enabled Web applications is also installed on installing Atlas. ...

Attended Windows Vista and Office 2007 launch

Today I attended Windows Vista and Office 2007 launch in Washington D.C. The event took place in Washington Hilton hotel. I was really impressed with some of the new features in Windows Vista like the new dazzling interface, flip 3d windows, fast search, gadgets, parental controls etc. The menus in Office 2007 are replaced by what Microsoft calls ribbons. There are many new features but they are not compelling enough to convince me to switch from Office 2003. Finally as an incentive to attending the conference each of us received an Office 2007 copy and a T-shirt. Microsoft has put up a new website (DinnerNow.net) that leverages several new Microsoft technologies like IIS7, ASP.NET Ajax Extensions, Linq, Windows Communication Foundation, Windows Workflow Foundation, Windows Presentation Foundation, Windows Powershell, and the .NET Compact Framework. You can also download the whole source code for the site starting Jan 31st, 2007 to look at how all these technologies work together.

Error "The project type is not supported by this installation." while creating ASP.NET AJAX enabled Web Application

Last night I downloaded and installed ASP.NET 2.0 AJAX Extensions 1.0 on my home computer. When AJAX extensions are installed, ASP.NET AJAX Enabled Web Application project template is also installed. I tried creating a new project by selecting ASP.NET AJAX Enabled Web Application and I got an error some thing like below. The project file 'C:\Inetpub\wwwroot\.....\AJAXTest.vbproj' cannot be opened. The project type is not supported by this installation. Upon Googling a bit, I found that we need to install Visual Studio 2005 Web Application project. and VS 2005 hot fix to support Visual Studio 2005 Web Application project. The hot fix should be installed first. Please follow the link to learn more. http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

Rare Videos of Warren Buffet

I was browsing throught Google Videos today and came across some videos on Warren Buffet. The videos talk about Warren Buffet's life, his investment philosophy, his friend ship with Charlie Munger and Bill Gates and his philanthropy. I have read a book on Warren Buffet but haven't seen him talk till now. The videos are made by Charlie Rose in an interactive way and are very engaging even if you do not know anything about Warren Buffet. I have learned a lot from these videos. This video talks about Buffet's childhood, his family and marriage . http://video.google.com/videoplay?docid=6701318343299922276 This video talk about how Buffet made his billions http://video.google.com/videoplay?docid=-6208910876057109785&q=label%3A%22warren+buffett%22 This video talks about his friendship with Bill Gates and his charity gift to Bill &Melinda Gates foundation. http://video.google.com/videoplay?docid=-4846290947664386236&q=label%3A%22warren+buffett%22

A very useful Habit Tracking Application.

I ran across Joe's Goal Tracking Application on Delicious and I fell in love with it.It is one of those AJAX applications out there that is really useful and easy to use. It helps you keep track of your goals and even gives u reports on your progress. I recommend you give it a try. Here is a screen shot of my goals. You can find the app at http://joesgoals.com

WSE2 Tracing SOAP messages

Microsoft Web Services Enhancements (WSE 2.0) allows you to trace incoming and out going SOAP message. Monitor the trace files and purge the files before they become too big . If the files get too big, WSE 2.0 throws all kind of communication errors. My webservice is behind a firewall and is hosted in a windows service on a particular port (xxxx). The client (outside the firewall) communicates with the windows service over TCP. One fine day, the communication between the client and service broke. I found the following stack trace in my log file. From the stack trace, my initial thought was the service might be down and verfied the service to be running. Next, I connected my local system to the service and verfied that the communicate is fine. Since the service is running properly, I verified with the sys admin that the port (xxxx) on the router is mapped correctly to the server hosting the webservice. After banging my head and Googling for hours I could not come up with a definite reas...

Successfully installed and implemented Google Mini

Google Mini is Google's integrated hardware and software solution to index your organization's digital assets. You can learn more about Google Mini here http://www.google.com/enterprise/mini/ . Earlier our client, was using Microsoft's Index Server to index their digital assets. This index server was shared by several websites and is slowing things a bit. The server, I guess reached its capacity and could not crawl and index any new files added. We were looking at alternative solutions and stumbled upon the Mini. Google Mini is a powerful search appliance in a blue box of the size of a large Pizza Hut pizza box. It is very easy to set it up and configure. The whole things takes around an hour or so to have the basic search solution up and running. All you have to do, is to tell the Mini what URL paths it has to index and bang, the Mini is on its feet crawling the site. Things get a little tough and confusing when you start to change the look and feel of the results. To c...