Wednesday, July 2, 2014

jQuery: remove duplicates from string

data = "val1,val2,val3,val4,val5";
 arr =  $.unique(data.split(','));
 data = arr.join(","); //get unique string back with 

Tuesday, July 1, 2014

how to convert var into numeric in javascript

var test1 = new Boolean(true);
var test2 = new Boolean(false);
var test3 = new Date();
var test4 = new String("999");
var test5 = new String("999 888");

var n = Number(test1) + "<br>" + Number(test2) + "<br>" + Number(test3) + "<br>" + Number(test4) + "<br>" + Number(test5);


1
0
1382704503079
999
NaN

select records monthwise from database sql query

SELECT ID, fromDate, toDate
FROM  SessionSchedule
WHERE (DATEPART(m, fromDate) = 8)

8- august month

display none/block in css from codebehind in asp.net

pnl.Style["display"] = "block";

Sunday, June 29, 2014

get checkbox checked in gridview in asp.net

 foreach (GridViewRow row in GridView1.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox);
                if (chkRow.Checked)
                {
                    string name = row.Cells[1].Text;
               
                }
            }
        }

convert datetime format to date only in asp.net

  string sessionscheduleid, sessionname, sessionid, duration, startdate, enddate;
            DateTime fromdate, todate;
     
            fromdate = Convert.ToDateTime(hdffromdate.Value);
            todate = Convert.ToDateTime(hdftodate.Value);

            startdate = fromdate.ToShortDateString();
            enddate = todate.ToShortDateString();

send multiple parameters to javascript in asp.net

<a href="#" onclick="BindSessionId('<%#Eval("ID") %>','<%#Eval("SessionName") %>','<%#Eval("fromDate") %>','<%#Eval("toDate") %>','<%#Eval("SessionID") %>');"
                                                                            data-reveal-id="myModal" data-animation="fade">Invite </a>


 function BindSessionId(sessionscheduleid, sessioname, fromdate, todate, sessionid) {
            alert(sessionid);
            $('input[id$=hdfsessionid]').val(sessionid);
            $('input[id$=hdfsessionscheduleid]').val(sessionscheduleid);
            $('input[id$=hdfsessionname]').val(sessioname);
            $('input[id$=hdffromdate]').val(fromdate);
            $('input[id$=hdftodate]').val(todate);
        }