Posts

Enumerate Html Table Rows with JS/JQ Example

i was asked so that all the page tables will get a running number for their row, AND to keep these numbers with only ++ after filter, so lets go. how do i add a cells, a TD to an existing row TR? suprisingly super easy var firstRow = document.getElementById( "myTable" ).rows[0]; var x = firstRow.insertCell(0); x.innerHTML = "New cell" ; cool. not lets spam all tables with a new cell var newCellIndex = 0; function AddNumerationsCells() {     var allTables = $( "table" );     for ( var i = 0; i < allTables.length; i++) {         allRows = allTables[i].rows;           if (allRows[j].cells[0].tagName == "TH" ) {                 var newTH = document.createElement( 'th' );            ...

cms מומלץ

mvc - http://www.orchardproject.net/  by gnadysh  

SQL Group By And Group_Concat Exapmle

SELECT        SUBSTRING((SELECT ', ' + CAST([קוד זיהוי] AS VARCHAR(20))  FROM [dbo].[All] AllSub      WHERE AllSub.משפחה = AllMain.משפחה      For XML Path('')), 2, 8000) AS [קוד זיהוי]      FROM [dbo].[All] AllMain GROUP BY משפחה, [שם] ,[רחוב] ,[מספר בית], [עיר]; point is that whatever field that is not in the GROUP BY the SQL Server wants you to group it somehow, and you need to to this XML trick for each one.  

Image Rotator by Genadysh example

http://jsbin.com/ijawag/4/edit Genadysh: http://blogs.microsoft.co.il/blogs/genadysh/

Do Stuff Every Request

say i want to update the login table everytime the user makes any request scenario 1: no webmethods or ajax: from the great collection of events in Global Asax we have 3 that fires with each request And knows the Session: void Session_Start ( object sender, EventArgs e){} void Application_AcquireRequestState( object sender, EventArgs e){} *here is ur code like pageload ect. btw void Application_PostRequestHandlerExecute ( object sender, EventArgs e){} so in any of those i can put an sql query and use Session.SessionID or Session["myvar"] NOTE! that since only PostRequest is executed after ur page finished his code that any changes made to the Session will only appear to him. Also in the very 1st run it will always be empty. scenario 2: webmethods or ajax: well i only tested that with page webmethods and PageMehtods, $.ajax and $.post client side. i found out a few nice thing, fisrt of all from these 3 event only Application_AcquireRequestSt...

Run JS from C#, RegisterStartupScript example

ScriptManager .RegisterStartupScript( this .Page, this .GetType(), "temp" ,     "<script type='text/javascript'>ArrangeDGV();makeEfferctForGrid();</script>" ,     false ); just put it somewhere in the page class and it will run the relevant JS funcs, very usefull with UPP

How to position Modal Dialog

position: [350, 400]

MySql Left Join Where Column Is Not Value

well, usually ppl do stuff like SELECT A.* FROM A LEFT JOIN B ON A.id = B.id_of_A WHERE B.X IS NOT NULL but i had a better situation i had multiple left joins and one of the tables had all kind of values where i needed on of them so its like SELECT A.*, C.c1, D.c1 IF (B.value = 'myVal', 1, 0) AS bval  FROM A LEFT JOIN B ON A.id = B.id_of_A LEFT JOIN C ON A.id = C.id_of_A LEFT JOIN D ON C.id = D.id_of_C so if u out some extra left joins there OR A->B is 1->n our if is not so good like Table B: id_of_A | value 1  | 1 1  | 2 1  | 3 1  | 4 1  | 5 2  | 4 2  | 5 and what if i want to WHERE this IF (WHERE bval = 1)? maybe some1 thinks right join but that will cut the rest of my info so i need a left join that is a right join ha ha!! well we can make it work like this: SELECT A.*, C.c1, D.c1, B.value FROM A LEFT JOIN B ON A.id = B.id_of_A           ...

Advanced HtmlTable / GridView auto sort example

this is an expansion for this http://bresleveloper.blogspot.co.il/2012/09/easy-sort-html-table-grid-view-using.html this time i just decided to bring all the code and comment it example http://jsbin.com/agijer/5/edit //* @author James Padolsey ( http://james.padolsey.com ) http://james.padolsey.com/javascript/sorting-elements-with-jquery / jQuery.fn.sortElements = ( function () {     var sort = [].sort;     return function (comparator, getSortable) {        getSortable = getSortable || function () { return this ; };         var placements = this .map( function () {             var sortElement = getSortable.call( this ),                   parentNode = sortElement.parentNode,  ...

JQuery set a selected by text or value

this little thing was anoying enouth to find $( "#myDropDownList option:selected" ).text($( "#Whatever" ).val()); $( "#myDropDownList option:selected" ).val($( "#Whatever" ).val());