Filed under ASP.NET by Lord TCT on 19 June 2010 at 2:05 pm
one comment
If you’re using Microsoft ASP.NET AjaxToolkit’s AsyncFileUpload placed inside a webform nested in a master page, chances are you’ll be faced with a baffling error message “The file attached is invalid”. No amount of manual troubleshooting and breakpoint-ing help because there’s no complete error messages (or even any that makes sense).
The reason: The client side script got confused because it couldn’t find the predicted ClientID.
The solution: Add ClientIDMode=”AutoID” to your markup!
Filed under ASP.NET, Windows by Lord TCT on 8 June 2010 at 11:52 pm
no comments
Developers new to Active Directory programming might find it frustrating that the ActiveDirectoryMembershipProvider example codes provided by Microsoft does not seem to work, at least on Windows 2008 R2 with ASP.NET 4.0 using “logon” usernames eg. “administrator”, “domain\joe”.
The reason is because the ActiveDirectoryMembershipProvider by default maps username to as UPN username (User Principal Name, ie. joe@domain.com) instead of SAM account name (Security Accounts Manager, ie. administrator, domain\joe).
To enable logging on using SAM account name, add attributeMapUsername=”SAMAccountName” to your web.config:
Filed under Linux, Programming Tips by Lord TCT on 12 June 2009 at 4:34 pm
no comments
Ever wanted to grab the output of a command via C++?
In PHP, we are all very familiar with @exec and popen, but what about C++?
Try this:
string cmd = "/usr/bin/netstat -na";
string OutString;
FILE *FileStream;
char stdbuffer[1024];
FileStream = popen(cmd.c_str(), "r");
while (fgets(stdbuffer, 1024, FileStream) != NULL)
OutString.append(stdbuffer);
pclose(FileStream);
- The first 3 lines are variable declarations.
- This is followed by popen command which opens a pipe to the external program. r here means to read from the program output.
- We will now use a 1024 character buffer to read the pipe until a null terminator is encountered.
- Remember to close the process pipe once you’re done!
You ask: “What if I want to have the stderr captured as well?”. No problem! Just add:
2>&1
to the back of your command, just like how you would do it in BASH.
Filed under Visual Basic by Lord TCT on 22 March 2008 at 10:19 pm
no comments
Surprisingly, one of the most useful extension to Microsoft Visual Studio goes largely unnoticed: Visual Basic PowerPack.
Think of Visual Basic PowerPack as the managed code reincarnation of a collection controls that made life easy on VB6 but were dropped since VB7:

Controls include PrintForm, LineShape, OvalShape, RectangleShape and DataRepeater. Oh those good old days are back!
Recent Comments