Set a js variable in a html include
- by user102533
I have a ASP.NET page that uses the include method for header. I am adding a JS variable that I access from JS functions
In head.htm
<script language="javascript" type="text/javascript">
var render=<%= RenderProperty %>;
</script>
The RenderProperty is a method in the base page class (a .cs file that inherits from System.Web.UI.Page)
It looks something like this:
private bool _renderProp = false;
public bool RenderProperty
{
get
{
return _renderProp;
}
set
{
_renderProp = value;
}
}
On a page by page basis, I set the RenderProperty in the Page_Load of a aspx page
protected void Page_Load(object sender, EventArgs e)
{
RenderProperty = true;
}
I get a compile time error that says:
The name 'RenderProperty' does not exist in the current context
C:\...\head.htm