Posts

Roadblocks utilizing ASP.NET 3.5 and ASP.NET AJAX

Below is a listing of known bugs of the ASP.NET 3.5 and ASP.NET AJAX and the resolution. Calendar control extender http://forums.asp.net/p/1110311/2780472.aspx#2780472 Problem: Calendar extender would show random transparent weird popup upon clicking. (unbelievable that this can pass QA in the first place) Resolution: Add a dummy CalendarExtender outside of updatepanel. The calendarextender might need to associate with a dummy invisible textbox and invisble image button too. ----------------------------------------------------------- ASP.NET AJAX CalenderExtender again, this time on the days cells being blocked. Problem: If you have a couple of CalenderExtender in your page and asking UI designer to design the CSS separately. You would be very likely getting this. The problem is the td, tr and div tag being overridden by the CSS . Resolution: Have a more specific CSS for your calendarextender. The rule of CSS is the most specific one prevail.Use this (MyCalendar) in the CssClass attrib...

WCF - Reading from Application Configuration File - config section - system.serviceModel

I can't find any example on the web for this, so i guess it could be helpful. This is a simple example to show a way to read the system.serviceModel configuration section in application/web configuration file. Something like for ConnectionString, there is a straightforward class for that, ConfigurationManager.ConnectionStrings["keyname"].ConnectionString Codes snippet below ServiceModelSectionGroup group = ServiceModelSectionGroup.GetSectionGroup(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)); //suppose if there is only one endpoint if(group.Client.Endpoints.Count < 0) { uri = group.Client.Endpoints[0].Address.AbsoluteUri; }

Stop Symantec Endpoint Protection Weekly Scheduled Scan Momentary

The intention of weekly scheduled scan is good, it helps to safeguard and diagnose your computer from malware. It is a setting set by the most system administrator that any computer with endpoint protection installed would need to oblige this and have it scan every week. It is a centralized setting where users can't change it at the user end. However, for an advanced user like myself who knows how to take care of my computer, running a PC scanning even on my peak hours are really intrusive. Therefore, after some trial and error, i notice if I use process explorer to kill the rtvscan.exe while it is running, it would force the scanning to terminate itself. And the best thing is antivirus would still be up and running and no restart required. Probably you would need to enable back the protection at the setting where it would prompt you too. That is all you need to do. (this is my backdoor trick, use it at your own risk.)

Visual Studio .NET 2008 - Some conditional breakpoints not getting triggered and workaround.

If you read some debugging tips or reference on conditional breakpoint. You would notice that what is in the instruction should be straightforward and there is no reason why it won't work when you try it out. However, there are times when you set conditional breakpoint , a very simple one like say in you code, string a[] = {"21", "123", "32", "1234", "sds"}; foreach (string myString in stringArray) { Console.WriteLine("myString = " + myString); //conditional breakpoint set here. } conditional breakpoint set as myString == "1234" but to your surprise, it would not break and stop there. It is a very simple thing you would do but it just seems not working. For most people, they would just set normal breakpoint there and run a few more iterations and bypass the use of the conditional breakpoints but this is not my liking. This is a VS.NET function that I would really like it to work. It is af...

C# 2.0 syntax reference

readonly - member variable of class where can only be initialized once in constructor. yield - contruct return for IEnumerable e.g. IEnumerable GetNumbers() { yield return 1; yield return 2; yield return 3; yield return 4; yield break; } This is return a 1,2,3,4 list. this() - calling class constructor this[] - [] operator override e.g public int this[int i] { get { return 1; } } generic programming //where TbaseClass is use for T calling function class C1<T>:D1 where T:TbaseClass class B1 : C1<myInherittedTbaseClass>

C# pass-by-value and reference type

If you are coming from C/C++ programming background. You would be accustomed with heavy use of pass by reference (or pass by pointer) as a way to improve the performance, update the variable passed in and reducing memory consumption. It is so common, that most C/C++ function written to be efficient would be passing by constant reference (if they do not wish to allow variable passed in get updated) Like void myFunction(const MyClass & param) So, you are rest assured that variable pass in would not get updated. For C#, there is no such thing as const reference. But, there is pass-by-ref, unsafe pointer and pass-by-value. So, to ensure that your variable passed in to function not get updated. You would naturally think of using pass-by-value. However, there is a catch for pass-by-value if your object is of reference type (class, interface, delegate, objet, string) Value type variable store value but reference type variable store references to object. So, even the reference is passe...

Smart Thinking & Lateral Thinking (Edward De Bono)

(These are just my own "personal" summary to Edward De Bono smart thinking & lateral thinking materials where I have came across some of his books lately. (for my own reference) Please visit authorized Edward De Bono web sites if you are interested in these topics. http://www.edwdebono.com/) Lateral Thinking - 6 thinking hats White Hat - Based on hard data, facts, figures and numbers Red Hat - Based on hunch, gut feeling emotional point of view Black Hat - Pessimistic, sad & negative view but logical. Yellow Hat - Glad and possitive but logical view. Green Hat - Alternative, creative and sprouting new idea. Blue Hat - Step back and take care of process of thinking. Deciding hats to be used and summarize what have been thought. Critical Thinking - A way to minimize mistake in thinking. Creative Thinking Provocative Operation - Come up with an absurd idea. Then, think of "movement". Movement - Think of ways to make provocative operation / ran...

DOS prompt batch

Was trying out something on batch file, quite interesting though has limited features. But would be a quick way to delivery some solutions. Always check what batch can do before want to write a program for it. Good place to start on batch programming at -> http://www.allenware.com/icsw/icswidx.htm SET MYLOCATION = C:\Folder REM A reversible CD command where you can go back where you REM came from. pushd %MYLOCATION% REM check for file existent if not exist *.txt goto ERROR for %%file in (*txt) do type "%%file" >> mySingleFile.txt IF ERRORLEVEL 1 goto ERROR popd :ERROR echo Error occurredEXIT /B 1

XSL - Altering child attribute with original parent attribute

XML <?xml version="1.0" encoding="utf-8"?> <Items xmlns="http://www.abc.com" xmlns:myns="http://www.abc.com"> <Item attr="1"> <field1>My Content 1</field1> </Item> <Item attr="2"> <field1>My Content 1</field1> </Item> <Item attr="3"> <field1>My Content 1</field1> <field2 innerAttr="a">My Content 2</field2> </Item> </Items> XSL <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myns="http://www.abc.com" xmlns="http://www.abc.com" > <xsl:output omit-xml-declaration="no" indent="yes"/> <xsl:namespace-alias stylesheet-prefix="#default" result-prefix="#default...

Resumeable Windows File Copying

Recently having need to copy huge files or a whole set of files more often over the network. Thinking of finding a tool like getright. So, this is the tool I found really useful. Robocopy - http://en.wikipedia.org/wiki/Robocopy How it fit my usage is with command like below. robocopy \\source\dir \\destination\dir /W:15 /R:30 /E /Z W = 15 seconds pause should it failed R = Retry of 30 times Z = Restartable mode E = Copying content recursively (including subfolders content) (use /MIR if want to mirror both side of content instead of /E. /MIR would remove the destination file if not found in source)

Adding notepad, command prompt, powershell run here context menu

Create a text file, name it temp.reg. Then, for each application you want to add it context menu. Copy and paste to the temp.reg. Then, just execute the temp.reg by double clicking it. For Powershell -------------- Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\Directory\shell\powershell]@="PowerShell Here"[HKEY_CLASSES_ROOT\Directory\shell\powershell\command]@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'" Command Prompt ----------------- Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\CommandPrompt] @="Command Prompt Here" [HKEY_CLASSES_ROOT\Directory\shell\CommandPrompt\command] @="C:\\Windows\\system32\\cmd.exe /k pushd %1" Notepad ---------- Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Edit in Notepad] [HKEY_CLASSES_ROOT\*\shell\Edit in Notepad\command] @="notepad.exe \"%l\""

Searching word/phrase in a very large text file in windows

1. Firstly, you need to have a grep tool (like Unix). For windows, you can try http://www.wingrep.com/ 2. Then, you just search a word/phrase in the text file with simple query or advanced regular expression query in the wingrep. 3. You should be getting the line number in the grep search result. 4. Then, start dos prompt. 5. Type command - "more +123 YourHugeFile.txt" where 123 for example is the line number you wish to see starting from. 6. Then, you should see some content in "more" dos screen. 7. If you wish to scroll line by line in "more", key in "enter/ret". if you wish to go page by page, key in "space" 9 Once you are done, type "CTRL + C" to exit.

Virtual PC setting - resetting MAC address.

In the case where you would want to change the IP address by forcing the DHCP to re-assign a new IP to you Virtual PC. (or in the case you are using the same *.vmc file and you don’t bother to recreate a new one) Stop your virtual machine. Then, in your *.vmc, look for <ethernet_card_address type="bytes">0003FFxxxxxx</ethernet_card_address> Remove the number so the line appears as follows: <ethernet_card_address type="bytes"></ethernet_card_address> After you remove the number, Virtual PC will create a new MAC address the next time you start the virtual machine. And in turn, DHCP will assign u a new IP address for your virtual machine.

SQL server IDENTITY and seed

One can make a column to be auto increment by setting it as identity. CREATE TABLE dbo.MyTable ( MyID int identity(1,1), MyName nvarchar(20) ) One can make it start from certain number by setting the seed identity(1000, 1) So, the first row would have id 1001 One can also increase the seed even with some data in the table say already the record run up to 102. If set seed to 200, the next record id would be 201. (one catch is if seed is 1, it will start with 1. But if seed as 11, it will start at 12.) Also one note is that the seed can not be smaller than the existing one as it would not make any changes. (the existing seed number can be check in the property of the column) For reseting the identity seed. The DBCC command is needed like DBCC CHECKIDENT('MyTable', RESEED, 1) It will attempt to start over from 1 and if found some ID with the same number exist, it will skip that ID and use next number. (This is done by the MSSQL in best effort mode. It is not predictable and guaran...

Getting started powershell

After installing powershell 1.0. The $profile will not be added. The $profile is equivalent to .profile in ksh where it initialized when it started. So, to add it. You need to specify permission first (like below), then, create the $profile. (you can echo $profile to see where the file resides in the windows) Set-ExecutionPolicy RemoteSigned new-item -path $profile -itemtype file -force

Fix login of restored DB (SQL server 2005)

After when restored Database from *.bak file. The associated login will not be restored into the MSSQL. And when trying to create the same login in the security tab in managemement studio. It will prompt Error 15023: User already exists in current database. The off hand workaround that normally one would do would be drop the user in the database user login and recreate again. like USE YourDB GO EXEC sp_dropuser 'YourRestoredDBLogin' GO The better way would be run command below to check the orphan logins. USE YourDB GO EXEC sp_change_users_login 'Report' GO then below to restored the login with command below. It will retain the settings that you have. USE YourDB GO EXEC sp_change_users_login 'Auto_Fix', 'YourRestoredDBLogin', NULL, 'YourRestoredDBLoginPassword' GO Reference: http://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/

Winmerge - To be able to see non English characters in compare windows

Firstly, Change your windows Language for non-unicode program to the language you want.(In Regional and Language Option in control. refer Windows Help file) Then, In winmerge – Edit – Options – Codepage (tab) Tick ‘According to WinMerge User Interface’ Then, In View – Select Font – choose the font which has needed font script. E.g. CHINESE_GB2312 for simplified chinese Then In winmerge – Edit - Refresh Selected (if you are already viewing something.) and no restart required to see the changes.

Win32 SendMessage equivalent in Javascript

Problem Statement: Custom control written in Javascript can't immediate trigger the onchange event if the textbox control are updated using the code. e.g. ctrl.value = "123"; It will only trigger the onchange when move focus to another control. Solution: Win32 SendMessage equivalent in Javascript IE: element.fireEvent('onchange'); And via DOM2 Events (for Gecko): var evt = document.createEvent('HTMLEvents'); evt.initEvent('change', true, true); element.dispatchEvent(evt);

Eclipse CVS Repository Integration Watch Out

Eclipse has CVS version control integrated. It is nifty but some watch out to be careful of. 1. Always Refresh your project/ whole thing in the project view before performing Team - Synchronize With Repository or else you would not see your changes during synchronization and causing your changes GONE if you choose to update the files thinking your side have no changes!!! 2. Always use synchronize to check the changes. NEVER use the update (to overwrite local file with changes from server) or commit (to overwrite server/remote files with local file changes) to a folder directly. You would cause either server version get overwritten by your version if there are additional changes by others or your version get overwritten by server copy without doing the conflict checking and merge. 3. If you have already merged the changes (by comparing remote file and local file and use move change facility), your side with the server. Select ‘mark as merge’ and then commit.

MSSQL GROUP_CONCAT

This is using XML feature of the SQL server. (nothing new here) select Type, RestaurantNames from Restaurant AS A CROSS APPLY (SELECT RestaurantName + ',' FROM Restaurant AS B WHERE A.Type = B.Type FOR XML PATH('')) D (RestaurantNames) GROUP BY Type, RestaurantNames This is to get something like below (similar to MYSQL GROUP_CONCAT) Type |RestaurantNames ----- --------------- Chinese Food | Ah Yat Abalone, Liang Yah Yong Tau Foo, Indian Food | Kanna Curry House, Western Fast Food | Burger King, McDonald instead of multiple rows. like Type |RestaurantName ----- --------------- Chinese Food |Ah Yat Abalone Chinese Food |Liang Yah Yong Tau Foo Indian Food |Kanna Curry House