Wednesday, June 20, 2012

Maximum 255 character textbox counter set

<html>
<head>
  <link rel="canonical" href="http://www.example.com" />
<script language = "Javascript">
/**
 * DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

maxL=255;
var bName = navigator.appName;
function taLimit(taObj) {
    if (taObj.value.length==maxL) return false;
    return true;
}

function taCount(taObj,Cnt) {
    objCnt=createObject(Cnt);
    objVal=taObj.value;
    if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
    if (objCnt) {
        if(bName == "Netscape"){   
            objCnt.textContent=maxL-objVal.length;}
        else{objCnt.innerText=maxL-objVal.length;}
    }
    return true;
}
function createObject(objId) {
    if (document.getElementById) return document.getElementById(objId);
    else if (document.layers) return eval("document." + objId);
    else if (document.all) return eval("document.all." + objId);
    else return eval("document." + objId);
}
</script>

<body>

<fb:like ref="top_left"></fb:like>
<iframe src="http://www.facebook.com/l.php?fb_ref=top_left&fb_source=profile_oneline"></iframe>







<div id="content">
  <g:plusone size="small"></g:plusone>

    <script type="text/javascript">
      window.___gcfg = {
        lang: 'en-US'
      };

      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>


<font> Maximum Number of characters for this text box is 255.<br>
<textarea onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="Description" rows=7 wrap="physical" cols=40 Maxlength="255">
</textarea>
<br><br>
You have <B><SPAN id=myCounter>255</SPAN></B> characters remaining
for your description...</font>
</body>

</html>


Remove duplicates from a datatable..

using System.Data;

using System.Linq;

DataTable dt = ds.Tables[0];

DataView dv = new DataView(dt);

string cols = string.Empty;

foreach (DataColumn col in dt.Columns)

{

if (!string.IsNullOrEmpty(cols)) cols += ",";

cols += col.ColumnName;

}

dt = dv.ToTable(true, cols.Split(','));

ds.Tables.RemoveAt(0);

ds.Tables.Add(dt);

To select time format in hh:mm (AM/PM) format


SELECT REPLACE(REPLACE(RIGHT('0'+LTRIM(RIGHT(CONVERT(varchar,getdate(),100),8)),7),'PM',' PM'),'AM',' AM')