Wednesday, November 02, 2011

Excel Last Index Of

It is challenging sometimes to find last occurrence of a character in a string. I hope the following formula can help: =SEARCH("@",SUBSTITUTE(A1,"\","@",LEN(A1)-LEN(SUBSTITUTE(A1,"\","")))) * Considering that the Text is in cell A1, and we are looking for "\" character.

Friday, December 24, 2010

Build vs Rebuild

 

Build means compile and link only the source files that have changed since the last build, while Rebuild means compile and link all source files regardless of whether they changed or not. Build is the normal thing to do and is faster. Sometimes the versions of project target components can get out of sync and rebuild is necessary to make the build successful. In practice, you never need to Clean.

Build or Rebuild Solution builds or rebuilds all projects in the your solution, while Build or Rebuild <project name> builds or rebuilds the StartUp project. To set the StartUp project, right click on the desired project name in the Solution Explorer tab and select Set as StartUp project. The project name now appears in bold.

Compile just compiles the source file currently being edited. Useful to quickly check for errors when the rest of your source files are in an incomplete state that would prevent a successful build of the entire project. Ctrl-F7 is the shortcut key for Compile.

  • All source files that have changed are saved when you request a build/rebuild, so you don't have to save them first.
  • When you run your executable (F5 or Ctrl-F5), Visual Studio saves all your changed source files and builds anything that changed, so you don't need to explicitly do those steps every time. This allows for quick "trial and error" debugging.

Incidentally, if you like those little Visual Studio keyboard shortcuts, you can download posters of the C# and the VB.Net ones, respectively (I am personally a big fan of using keyboard shortcuts :) ).

 

Visual Studio 2010

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=92ced922-d505-457a-8c9c-84036160639f

 

Visual Studio 2005

C#: http://www.microsoft.com/downloads/details.aspx?FamilyID=c15d210d-a926-46a8-a586-31f8a2e576fe&DisplayLang=en

VB.NET: http://www.microsoft.com/downloads/details.aspx?FamilyID=6bb41456-9378-4746-b502-b4c5f7182203&DisplayLang=en

 

 

Friday, July 09, 2010

Windows7: Customize SendTo menu

I have always used "Send To" menu when I need to open a file in Notepad. This is much easier than going through Open With menu. However, customizing Send To menu in Windows 7 is a little different then the previous versions of Windows.

Send To menu is now under the Roaming - AppData folder. Here is how you can access it, copy and paste the following in your Windows 7/Windows Vista Search box or Run Dialog.

%UserProfile%\Appdata\Roaming\Microsoft\Windows\Sendto

Right click on the folder and click on New -> Shortcut

 
Send to menu before and after adding shortcut to Notepad:

Saturday, May 29, 2010

SQL03070: This statement is not recognized in this context

Recently I have started working with VS2010 and Fx4. There have been various challenges. We also introduced a new Database Project in our solution. And found this error.

The reason for this error is: the project system expects the stored procedure as a create statement only.  The additional statements to drop if existing are not necessary within the project system.  Project deployment takes care of detecting if the sproc already exists and if it needs to be updated.

To resolve this error you can simply remove the additional statements other then your create SP, Function etc.

OR

Exclude the file from build. Right Click on your file in Solution Explorer, Click Properties > Build Action > Not in Build

Monday, January 11, 2010

ASP.NET TreeView - after Async Load

I had to struggle a little with a problem in using ASP.NET TreeView, which I had customized for one of the projects. The issue was to execute some client side script, after the TreeView has completed loading Nodes asynchronously. However, as I found out - unlike other controls TreeView does not provide a ready mechanism to hook custom code after the nodes are loaded asynchronously (using PopulateOnDemand property)


Problem description:

When we use ASP .NET TreeView control, it provides us an option of lazy loading or asynchronous loading of Tree Nodes. This is taken care of by a whole lot of JavaScript that are added to the page by adding reference to couple of WebResource.axd files:
a. First script file contains Tree View html updation scripts and
b. the other script file contains Async postback related scripts

When a node is marked for loading its contents Asynchronously (using node.PopulateOnDemand = true), a JavaScript method - TreeNode_PopulateOnDemand is called on expand icon click.
This internally calls the Async Page load methods. And finally gives the content to be updated to another method - TreeNode_ProcessNodeData.

Solution:

The fix that I worked out was to modify the TreeNode_ProcessNodeData function itself, to add my custom method once it completes its processing. Here is the code snippet to modify the TreeView_ProcessNodeData:

function TreeView_UpdateProcessNodeData(){
    var fnStmt = TreeView_ProcessNodeData.toString();
    fnStmt = fnStmt.substring(fnStmt.indexOf("{") + 1);
    fnStmt = fnStmt.substring(0, fnStmt.length-1);
    fnStmt += "\nMyCustomMethod();";
    TreeView_ProcessNodeData = new Function("result", "context", fnStmt);
}