Share The Code Concept

312days since
Republic Day

SharePoint Utility

Create a sharepoint Utility to make the webservice deployment eazier.

JavaScript

Contents

    No headings.


    Hidden Input box How to/Why ?

    posted Sep 18, 2008 1:39 AM by Praveen Krishna R   [ updated Oct 11, 2008 12:33 AM ]

    Hidden Inputs

    Many times you may need to pass values from web client to web server. For those scenarios the Hidden inputs are useful. 

    In HTML you create it like this


    <input ID="txtQuery" runat="server" type ="hidden"/>


    And you can set the values for it like


    document.getElementById("myHiddenVar").value = "myValue"

    In ASP.NET you use txtQuery object to get the value.

    Trim function for Javascript

    posted Sep 3, 2008 6:26 AM by Praveen Krishna R

    Trim(s)

    function Trim(s) {
    return s.replace(/^\s+|\s+$/g,"");
    }

    Function to Page the contents using a <TABLE/>.

    posted Sep 1, 2008 8:32 AM by Praveen Krishna R   [ updated Sep 17, 2008 4:31 AM ]

    Code for Paging

    function PageContents ( ParentTableId, RowID){
        var table = document.getElementById(ParentTableId);
        var ele;
        for (var r = 0; r < table.rows.length; r++){
            ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,"");
            if (table.rows[r].id.toLowerCase().indexOf (RowID.toLowerCase()) >=0)
                table.rows[r].style.display = '';
            else table.rows[r].style.display = 'none';
        }
    }

    How to Use it ?

    Display only as much as rows in the table as you want. Set the style of the remaining ones to style="display:none".
    You can place any control say label to hold the links to the other pages at the bottom.
    eg.
    <label onclick="javascript:PageContents('Table111', 'id224');">[4]</label>
    The first parameter is the parent table which holds the entire contents. We achieve the paging by hiding the rows 
    in the table. The second parameter is part of the ID of the row which is to be shown while clicking. Say you can generate the IDs of the Table Rows like id224-1, id224-2,... while creating the rows, and which will be useful for hiding the unwanted rows in the page.

    ‹ Prev    1-3 of 3    Next ›