GridView or DataGrid only allows you to delete one row each time and it becomes inefficient and tedious if there are multiple rows need to be deleted. In this post, I will demo how to add a check box in front of each row and also a check box in the header of the grid to check/uncheck all check boxes, then with a delete button to delete those checked rows in a batch mode. I […]
Yearly Archives: 2008
This has been used a lot on those “sign up” forms. User has to select a check box indicating “I read and agree to the license agreement”, or something like that, before he/she can submit the form. Of course, with ASP.NET, you can let user submit the form and then check the state of the check box in the Button.Click event handler to prompt the user if the check bos is not checked. But my […]
(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 […]