Calling javascript in cs file

Posted by Chaithragm under C# on 3/15/2013 | Points: 10 | Views : 1422 | Status : [Member] | Replies : 1
i have a java script by name showLoadingIco()
i need to call this javascript when the button click
i have used this but its calling after the functionalites
protected void showLoadingIco()
{
ScriptManager.RegisterStartupScript(this.Page, typeof(Page), Guid.NewGuid().ToString(), "showLoadingIco();", true);
}
protected void upload_btn_Click(object sender, EventArgs e)
{
showLoadingIco();
try{
}
catch{
}
}
showLoadingIco();must be called before executing the try block.where i need to place the method




Responses

Posted by: Santhi on: 3/15/2013 [Member] Starter | Points: 25

Up
0
Down

Hi

Try this code:
C# code:

 System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "fun();", true);  


Here fun()
refers to the name of the function which you have written on javascript

Script:
  function fun() {


// your code
}




Thanks & Regards,
Santhi .V

Chaithragm, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response