Set a js variable in a html include

Posted by user102533 on Stack Overflow See other posts from Stack Overflow or by user102533
Published on 2009-08-06T17:02:12Z Indexed on 2010/03/19 0:01 UTC
Read the original article Hit count: 234

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#