How to use a c# sring in javascript
-
I want to use a string from WebApplication1.aspx.cs in the WebApplication1.aspx code behind (javascript).
Put a literal control in the javascript code: var bananas = '<asp:Literal id="Fruit" runat="server"/>'; Then put the string value in the literal, encoded as a javascript string: Fruit.Text = theString.Replace(@"\", @"\\").Replace("'", @"\'"); --- b { font-weight: normal; }
-
Put a literal control in the javascript code: var bananas = '<asp:Literal id="Fruit" runat="server"/>'; Then put the string value in the literal, encoded as a javascript string: Fruit.Text = theString.Replace(@"\", @"\\").Replace("'", @"\'"); --- b { font-weight: normal; }
-
I assume
Fruit.Text
is a ASP.NET textbox. How do I get the text inside the textbox intobananas
-
No, Fruit is not a textbox, it's the Literal element inside the javascript code. --- b { font-weight: normal; }