Tuesday, 25 March 2014

Confirm message box in jquery

  if (confirm("Do you want to delete this record!")) {alert('you clicked on OK button')}
else{alert('you clicked on CANCEL button')}

Monday, 10 March 2014

create cookies using javascript

/*-----( CREATING COOKIE )------*/

 var email =$('#txtUserName').val();
 var pwd = $('#txtPassword').val();
 var d = new Date();
    d.setTime(d.getTime()+(30*24*60*60*1000));
     var v_rememberMe = $('#RememberMe').is(':checked') == true ? "Y":"N";
    $('#RememberMe').is(':checked') == true ? (document.cookie = "email=" + email + ";expires=" + d.toGMTString() + "") : d.setTime(d.getTime() + (-31 * 24 * 60 * 60 * 1000)); document.cookie = "email=" + email + ";expires=" + d.toGMTString() + "";

/*-------( GETTING COOKIE VALUES )--------*/
$(document).ready(function () {

    var mail = getCookie("email");
    var expdays = getCookie("expires");
 
   // mail!= "" ? ($('#txtPassword').focus(); $('#txtUserName').val(mail)): $('#txtUserName').focus();
    if (mail != "") {
        $('#txtPassword').focus(); $('#txtUserName').val(mail); $('#RememberMe').attr('checked', true);
    }
    else { $('#txtUserName').focus(); }
});
/*----( Getting cookie by Name )----*/
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i].trim();
        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
    }
    return "";
}

Sunday, 9 March 2014

set checkbox list selection based on the DB values

  try
            {
string DBVal="1,2,3,";
                if (DBVal != "")
                {
                    string[] str = DBVal.Split(',');
                    foreach (var i in str)
                    {
                        ChkBoxList.Items.FindByValue(i).Selected = true;
                    }
                }
            }
            catch { }

getting checked list box values in asp.net

HERE WE CAN SEPERATE WITH ","

 var selected = ChkBoxList.Items.Cast<ListItem>().Where(x => x.Selected);
            foreach (var chkItem in selected)
            {
                string str += chkItem.Value + ",";
            }

Extracting Nupkg files using command line

Rename it to zip first then extract files as below 1.     Rename-Item -Path A_Package.nupkg -NewName A_Package.zip 2.     Make sure to repla...