Thursday, August 31, 2017

how to call javascript function in c#

Home.aspx.cs

protected void BtnLogin_click(object sender,eventargs e)
{

//when i click this button i need to call javascript function
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(@"<script language="'javascript'">");
            sb.Append(@"JavaScriptFunctionName();");
            sb.Append(@"</script>");
       System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "JSName",     sb.ToString(), false);

}


Home.aspx

<script type="text/javascript">
function JavaScriptFunctionName()
{
 alert('Called JS function.');
}
</script>



No comments:

Change default Port on Next.js app

 If any other app or process is running on port 3000 , you will get this error in your terminal Port 3000 is already in use. error Command f...