How to pass the variable value from codebehind to javascript

In this article i am going to show you how to pass the variable value from codebehind to javascript. It is quite easy and handy.

I have declared a protected type string variable Variable_codebehind in codebehind, assign a value to that variable on page load .

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

public partial class _Default : System.Web.UI.Page
    protected string Variable_codebehind;
    protected void Page_Load(object sender, EventArgs e)
        Variable_codebehind = "Ashish Blog";

Now, we going to diaplay this variable Variable_codebehind into html page using javascript.

<html xmlns="">  
<head runat="server"> 
<title>Ashish's Blog</title>
  <script type="text/javascript">
         ////Getting variable from code behind  
          alert("<%=Variable_codebehind %>");
<form id="form1" runat="server">