Wednesday, March 23, 2011

In ASP.NET, ENTER key on a FORM with a single Input Field, will automatically SUBMIT.

This happens in IE, Chrome, but not in Firefox.
Solution: add another hidden input field. Such as:

<div style="display: none">
    <input type="text" name="hiddenText" />
</div>


Reason:
Because IE and Chrome following HTML2.0 Specification exactly.
According to HTML2.0 Specification, 8.2. Form Submission:

When there is only one single-line text input field in a form, the
   user agent should accept Enter in that field as a request to submit
   the form.


Tuesday, March 22, 2011

CLEDITOR - JQuery WYSIWYG HTML EDITOR

CLEditor is an open source jQuery plugin which provides a lightweight, full featured, cross browser, extensible, WYSIWYG HTML editor which can be easily added into any web site


Demo
http://premiumsoftware.net/cleditor/

jQuery Mobile CDN

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>

Monday, March 21, 2011

How to find out common element(s) in two generic list by LINQ, LINQ Set Operations

int[] twos = { 2, 4, 6, 8, 10 };
int[] threes = { 3, 6, 9, 12, 15 };

// 6
var intersection = twos.Intersect(threes);

// 2, 4, 8, 10
var except = twos.Except(threes);

// 2, 4, 7, 8, 10, 3, 9, 12, 15
var union = twos.Union(threes);

Understand SQL Injection by code

If put the following string in the SSN text box
' ; DROP DATABASE pubs  --
Using the input, the application executes the following stored procedure, which internally executes a similar SQL statement.
SqlDataAdapter myCommand = new SqlDataAdapter(
                                "LoginStoredProcedure '" +
                                 SSN.Text + "'", myConnection);

The code INJECT into the user's malicious input and generates the following query.
SELECT au_lname, au_fname FROM authors WHERE au_id = ''; DROP DATABASE pubs --'
 
Reference: 
How To: Protect From SQL Injection in ASP.NET