Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Friday, 28 October 2011

Javascript to disable all ASP:ImageButton

if you want to disable all <ASP:ImageButton type controls using Javascript, you have to keep in mind that browser renders the controls this way

<input type="image" name="ctl00$btnUserHistory" id="btnUserHistory" title="User Activities" src="/Img/userhistory.gif" />

You see ctl00$ in the name as the button is inside a ContentPlaceHolder, so catch all inside or not write this function

function disableButton() {
        //Disable All Image Buttons       
        var ButtonsColl = document.getElementsByTagName('input');
        for (i = 0; i <= ButtonsColl.length - 1; i++) {
            if (ButtonsColl[i].getAttribute('type') == 'image') {
                ButtonsColl[i].disabled = true;
            }
        }
    }

Wednesday, 13 July 2011

Javascript Popup window causes parent font size increase?

If you are usnig Javascript popup window and its disturbing your parent font sizes use the ScriptManager.RegisterStartupScript instead.

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "newWindow", "window.open('MyPage.aspx?ID=" + MyID + "','_blank','status=1,toolbar=0,menubar=0,location=1,scrollbars=1,resizable=1,width=30,height=30');", true);