How to call JavaScript function from c# code ?

–Place the following code in your function in aspx.cs file

String fn = “window.onload=function(){try{showHide(‘hiddenRow’,’18′, document.getElementById(‘tr’)); }catch(error){alert(error.description);}}”;
if (!Page.ClientScript.IsClientScriptBlockRegistered(“callScript”))
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), “callScript”, fn, true);

// Here ‘tr’ in function parameter is the id of table row

–Place the below function in HTML file in scripting tag.

//client side javascript function

function showHide(rowId, rowVal, obj)
rowId = rowId + rowVal;
alert(rowId + ‘,’ rowval );


Pawan Kumar