Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.64/5 (3 votes)
See more:
in my project i have defined one static class [in App_code]

in static class defined one property


public static class ClassName
{
public static string Lock{get;set;}
}

i have assign some value to property
now i need to get this assigned property value in java script.
.
Posted
Updated 22-Aug-13 20:19pm
v4
Comments
Zoltán Zörgő 23-Aug-13 2:11am    
Of course you can. But not as you imagined. But everything else depends on the platform, technology and your application architecture. As long as you don't tell us these constraints we can not give you usable answer. Please improve your question!

1 solution

Please do some changes

1. Class name and property name can't be same.
2. Your property should be exist in code behind page of that page where javascript defined.

For example :

Code behind page is

C#
using System;

namespace UserInterface
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LockValue = "Sandeep";
        }
        public static string LockValue { get; set; }
    }

}


and your .aspx page where on button click calling property value

XML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="UserInterface.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function Submit()
        {
            var lock = '<%= LockValue %>';
            alert(lock);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="btnTest" runat="server" Text="Test" OnClientClick="Submit()" />
    </div>
    </form>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900