(I truly believe that a professional Web developer cannot live without JavaScript, and I have been busy playing with JavaScript lately and I will post some common but useful JavaScript code here.) Here is the JavaScript code: <script language=”javascript” type=”text/javascript”> function clearBox(id) { var txt = document.getElementById(id); if (txt.type != “text”) { alert(“Error: parameter type mismatch in clearBox function. TextBox type expected.”); } else { […]
Browser has a handy feature that remembers the information entered earlier in text boxes, and this feature can save you a lot of time when you fill up a form on-line. Sometimes, however, this feature may cause unwanted behaviors, even security concerns. For example, browser should not remember the credit card number that was entered. Another example is if you have a RegularExpressionValidator to validate a text box field, and if the text box has […]
Say you have a GridView control with a CheckBox column embedded. When the check box is checked, it fires an event. How can you find out the index of the corresponding row that contains the check box? Here is the code snippet: VB.NET code: Protected Sub chkSelect_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim cb As CheckBox = CType(sender, CheckBox) Dim gr As GridViewRow = CType(cb.NamingContainer, GridViewRow) If (gr IsNot Nothing) Then Dim i […]
1. Create a subfolder of App_Code folder named VBCode, and another subfolder named CSCode. 2. Change web.config file as follows: <compilation debug=”false”> <codeSubDirectories> <add directoryName=”VBCode” /> <add directoryName=”CSCode” /> </codeSubDirectories> </compilation> Reference: http://msdn.microsoft.com/en-us/library/t990ks23(vs.80).aspx
I came across a question asking how to change browser’s window status information when user moves the mouse over a button on an ASP.NET web page. The solution is to use JavaScript.In the Page_Load event handler, add the following two lines of code: Button1.Attributes.Add(“OnMouseMove”, “javascript:window.status=’Message’;”) Button1.Attributes.Add(“OnMouseOut”, “javascript:window.status=’Done’;) Note, the solution only works in Internet Explorer. FireFox by default disables the ability to change the status bar, because the status bar has been abused by spammers.
I came across to a post by Anil John talking about how to enforce password complexity by using regular expresion. Here is the regular expression he wrote: ^.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$ What it enforces is: Must be at least 10 characters Must contain at least one one lower case letter, one upper case letter, one digit and one special character Valid special characters are – @#$%^&+= This regular expression can be easily used for the RegularExpressValidator control in ASP.NET, and […]
If you are a Windows Server Administrator and notice an ASP.NET web application is malfunctioning, then how will you stop this application? Answer: Just delete the application from the server. Just kidding. 🙂 Real answer: Open up the web.config file of the web application, then change httpRuntime to false. Like this: <system.web> <httpRuntime enabled=”false” /> </system.web> Don’t forget to save the change. The modification of web.config will cause the application to restart, but because httpRuntime […]
For Windows applications, it might be a good idea to use the EventLog to log application errors because the EventLog is very powerful yet very simple to use. However, it might not be a good idea to use it to log ASP.NET web application errors. Why? There are several reasons: It’s all about security. In the malicious cyber world, the security of the web application is a very big concern of any company, if not […]
If you are still having trouble installing VMWare Server 2.0 on your Ubuntu box after following my instructions, then I suggest you to give up VMWare Server and switch to a very nice Open Source software called VirtualBox. Here is the description of VirtualBox from its web site: VirtualBox is a family of powerful x86 virtualization products for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product […]
Not-so-good news: the Linux installation package of VMWare Server does not have a user-friendly graphic user interface. And very likely you will need to build the package yourself on your Linux box. It is why it is not easy or straight-forward to install VMWare Server on Ubuntu. (It’s a shame that the VMWare development team does not have a deb package for Ubuntu, or a working rpm package for Fedora Core) Download VMWare Server 2.0 […]