Set Property Value on Master Page from Content Page

Posted by Merk on Stack Overflow See other posts from Stack Overflow or by Merk
Published on 2009-11-19T23:54:13Z Indexed on 2010/05/01 1:07 UTC
Read the original article Hit count: 329

Filed under:
|
|

Hello,

I tried following the advice posted here: http://stackoverflow.com/questions/1071920/set-property-value-on-master-page-from-content-page.

Specifically the last post about creating a class. However, visual studio keeps giving me an error on my default.aspx.cs page when i try to set the value:

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  

public partial class _Default : BasePage  
{  

    protected override int NavHighlight  
    {  
        get { return new{0} ; }  
    }  

    protected void Page_Load(object sender, EventArgs e)  
    {  

    }  
}

It throws an error on new, the error being: cannot inplicity convert anonymoustype#1 to int

Can someone tell me what i might have done wrong here?

Here's what my class looks like:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for BasePage
/// </summary>
public abstract class BasePage : System.Web.UI.Page
{
    protected abstract int NavHighlight { get; }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (this.Master != null)
        { 
            //value assignment 
        }
    }

 public BasePage()
 {
  //
  // TODO: Add constructor logic here
  //
 }
}

Thanks.

© Stack Overflow or respective owner

Related posts about roles

Related posts about ASP.NET