Tuesday, January 31, 2012

How to find the Gridview Row index(On click link button) at Runtime?


   Gridview Row index(On click link button):
       protected void lkbVideo_Click(object sender, EventArgs e)
        {
            int index = (((LinkButton)sender).Parent.Parent as GridViewRow).RowIndex;
            string strFilePath = GridView1.Rows[index].Cells[2].Text;


        }


    Gridview Row index(On click Image button):
      protected void ImgbuttonVideo_Click(object sender, EventArgs e)
        {
            int index = (((ImageButton)sender).Parent.Parent as GridViewRow).RowIndex;
            string strFilePath = GridView1.Rows[index].Cells[2].Text;


        }

How to hide Gridview column at Runtime?


           try
            {
                MonoManager objDataManager = new MonoManager();
                GridView1.DataSource = objDataManager.GetVideos();
                GridView1.DataBind();


                GridView1.HeaderRow.Cells[2].Visible = false;
                foreach (GridViewRow gvr in GridView1.Rows)
                {
                    gvr.Cells[2].Visible = false;
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }    

Saturday, January 28, 2012

createPopup() Method in JavaScript


    The createPopup() method is used to create a pop-up window.
    Its only support the Internet Explorer.
                       
Syntax: window.createPopup();
 
JavaScript code:
<script language="javascript" type="text/javascript">

    var popWindow;
    function windowFunction() {
        popWindow = window.createPopup();
        popWindow.document.body.style.backgroundColor = 'red';
        popWindow.show(200, 200, 100, 200, document.body);
   

</script>
 
HTML Code:
<input type="button" value="Popup Window!" onclick="this.windowFunction();">

How to use blink() Method in JavaScript

    The blink() method is used to display a blinking string.
    The blink() method only works in Firefox and Opera. It is not supported in Internet Explorer, Chrome etc.
 
Syntax: string.blink();
 
JavaScript code:
<script language="javascript" type="text/javascript">

    function BlinkFunction() {
        var myString = new String('Am I blinking?');
        document.write(myString.blink());
    }

</script>
 
Html code:
<button onclick="this.BlinkFunction();">Blink</button>

How to use print() Method in JavaScript

The print() method prints the contents of the current window.
 
Syntax: window.print();
 
JavaScript code:
<script language="javascript" type="text/javascript">

    function printFunction() {
        window.print();
    }

</script>
 
HTML Code:
<input type="button" value="Click to Print!" onclick="this.printFunction();" />

slice() Method


The slice() method extracts a part of a string and returns the extracted part in a new string.
 
Syntax: string.slice(begin,end);
 
JavaScript Code:
 
<script language="javascript" type="text/javascript">

    function sliceString() {
        var myName = new String('Anil Singh');
        alert(myName + '\n' + "After Slice=" + myName.slice(1, 5));
    }

</script>
 
HTML Code:
<button onclick="sliceString()">Slics Name here!!</button>

How to use sup() and sort() Method in JavaScript

The sup() method in JavaScript

The sup() method is used to display a string as superscript text.

Syntax: string.sup();

JavaScript Code:
 
<script language="javascript">
function supWin()
{
    var myString = new String('Two'); 
    document.write('Square'+myString.sup());
}
</script>

HTML Code:
<button onclick=”this. supWin();”>Click here!! </button>

How to use sort() Method in JavaScript

The sort() method sorts the elements of an array.

Syntax: array.sort(sortfunc);

JavaScrip Code:

<script language="javascript">
function sortArray()
{
    var myString = new Array('Anil','Singh','Kushinagar'); 
    myString.sort();
    alert(myString);
}
</script>

HTML Code:
<button onclick="sortArray()">Sort Array</button>