Difficulty transferring c# variable to aspx javascript value -


i'm having difficulty transferring c# variable javascript value in aspx file. have:

letschat.cs

using system; using system.collections.generic; using system.linq; using system.web; using microsoft.aspnet.signalr.hubs;  public class default {     public string pass = "password"; }  namespace signalrchat {     [hubname("mychathub")]     public class letschat : hub     {         public void send(string message)         {             clients.all.addmessage(message);         }     } } 

chat.aspx

<script type="text/javascript">     var pass = "<%=pass%>"; </script> 

why giving me following compilation error?:

the name 'pass' not exist in current context

the markup in chat.aspx can see members of own class -- partial class contained in code-behind. so, can't see pass variable, use:

var pass = "<%=new default().pass%>"; 

alternatively make pass static variable:

public class default {     public static string pass = "password"; } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -