Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
Passcode:
How to access c# variable in javascript in Simple solutions of Asp.net/Ado.net/C#.net(Dotnet)
3971 Views
Syntax
<script>
  function()
    {
       var varibleName = <%=this.VariavleName(Csharp)%>//getting value of c# variable to java script vaiable.
    }
</script>
Example
//from the same page taking value from c# variable to java script variable.
//Home.aspx inside script tag
<script>
    getName(){
      var name = <%=this.userName%>;
      }
</script>

//Home.aspx.cs page
string userName;
Best Lessons of "Asp.net/Ado.net/C#.net(Dotnet)"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details