String Array To List Or int[]

Wednesday, August 20, 2014
Convert String Array to Int array OR List<int> :

var aIDs=(r["AlertIDs"].ToString()).Split(',');
if (aIDs.Length > 0 && aIDs[0] !="" )
{
      List<int> alertIds = aIDs.Select(int.Parse).ToList();   // for convert to List<int>
    //  var alertIds = aIDs.Select(int.Parse);                         // for convert to int[]
}

Hide All TR after 5th TR of a Table by JQuery

Hide All TR after 5th TR of a Table by JQuery :

 $('#tbcompose > table:first tr:gt(5)').hide();

Submit button in MVC by Html Helper

Tuesday, June 10, 2014
In this way you can add new property with Htmlhelper :

public static MvcHtmlString Submit(this HtmlHelper helper, string name, string value, object htmlAttrib = null)
{
   var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttrib);
   var builder = new TagBuilder("input");
   if (htmlAttrib != null)
   {
      builder.MergeAttributes(attributes);
   }
   builder.Attributes.Add("type", "submit");
   builder.Attributes.Add("value", value);
   builder.Attributes.Add("name", name);
   builder.Attributes.Add("id", name);
   builder.AddCssClass("submit");
   return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing));
}

And you can you this like :

 @Html.Submit("submit")

Convert Int32 to Bool in C#

Wednesday, April 30, 2014
Bellow is the syntax for change Int to Bool :

bool result = Convert.ToInt32(maxLead[5]) == 1; 

Access URL details by JavaScript/JQuery

Thursday, April 24, 2014
http://www.refulz.com:8082/index.php#tab2?foo=789

Property    Result
-------------------------------------------
host        www.refulz.com:8082
hostname    www.refulz.com
port        8082
protocol    http
pathname    index.php
href        http://www.refulz.com:8082/index.php#tab2
hash        #tab2
search      ?foo=789

var x = $(location).attr('<property>');

No symbol in Textbox by JavaScripy

Tuesday, April 15, 2014
Within Script Block : 

var specialKeys = new Array();
    specialKeys.push(8); //Backspace
    specialKeys.push(9); //Tab
    specialKeys.push(46); //Delete
    specialKeys.push(36); //Home
    specialKeys.push(35); //End
    specialKeys.push(37); //Left
    specialKeys.push(39); //Right
    function IsAlphaNumeric(e) {
        var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
        var ret = ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode));      
        if ($('#txtCode').val().length > 7)
            ret= false;
        if (!ret)
        $("#errmsg").html("NO Symbol(s) & 8 Char").show().fadeOut("slow");
        return ret;
    }

where the HTML Like bellow :

<input id="txtCode" name="Code" class="/*easyui-validatebox*/ required form-control" required="true" style="width:100%" onkeypress="return IsAlphaNumeric(event);" ondrop="return false;" onpaste="return false;">
                    &nbsp;<span id="errmsg"></span>

--- on " onkeypress " event of that textbox that function filtered the input value & showing or inserted valied input . and it should not cross more than 8 char. 

SQL query with " IN " function with C# List

Tuesday, April 8, 2014
Here uLL is the List<BsonValue> ,because i am using MongoDB as a Database.
that's why i did convert to List<int> for compare with SQL.


string qry = "select count(*) from SendMessageHistory where SendDate> convert(varchar(10), getdate(),120) ";

                if (td != 1)
                {
                    if (td == 0)
                    {
                        qry += "and UserID=" + userID;
                    }
                    else if (td == 2)
                    {
                        AccountData dad = new AccountData();
                        var uLL = dad.GetUserByManagerID(userID);
                        List<int> ul=new List<int>();
                        foreach (var user in uLL)
                        {
                            ul.Add(Convert.ToInt32(user));
                        }
                         string types = string.Join(",", ul.ToArray());
                         qry += "and UserID In (" + types + ")";
                    }
                 
                }