Showing posts from October, 2012

Run JS from C#, RegisterStartupScript example

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp",
    "<script type='text/javascript'>ArrangeDGV();makeEfferctForGrid();</script>",

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
LEFT JOIN B ON = B.id_of_A

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
LEFT JOIN B ON = B.id_of_A
LEFT JOIN C ON = C.id_of_A
LEFT JOIN D ON = 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
LEFT JOIN B ON = B.id_of_A
                        AND B.value = 'myVal'
LEFT JOIN C ON = C.id_of_A
LEFT JOIN D ON = D.id_of_C

WHERE B.value IS (NOT)…

Advanced HtmlTable / GridView auto sort example

this is an expansion for this

this time i just decided to bring all the code and comment it

//* @author James Padolsey (

jQuery.fn.sortElements = (function () {
var sort = [].sort;
returnfunction (comparator, getSortable) {
       getSortable = getSortable || function () { returnthis; };
var placements = () {
var sortElement =,
                  parentNode = sortElement.parentNode,
                  nextSibling = parentNode.insertBefore(
returnfunction () {
if (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());

JQuery Modal Dialog how to add '-' (minimize)

this is a nice trick
1st to put the '-' in out modal title bar (this is after opening the dialog):

var header = document.getElementById("divMyDialog").previousSibling;
var minusDiv = document.createElement("div");
minusDiv.innerHTML = "&nbsp; - &nbsp;";
minusDiv.setAttribute("class", "divMinusForDialog")
minusDiv.setAttribute("onclick", "MinimizeDialog()")

also put these JS functions:
function MinimizeDialog() {

function MaximizeConvDialog() {
the CSS is this with extra for out maximizer:.divMinusForDialog {

JQuey Modal Dialog Cancel the X

the title part is the a previous sibling element to your div element and indside it there is the 'X'

   autoOpen: true,
   open: function (event, ui) {
       var header = document.getElementById("MyDialog").previousSibling;