开发者

method in partial class not listed in intellisense

In VS 2010 I have created a test method in partial class stored in Default.Partial.aspx.cs within the same directory as Default.aspx.cs but it isn't recognized by the Default.aspx.cs

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

/// <summary>
/// Summary description for Default
/// </summary>
public partial class _Default : System.Web.UI.Page
{
    private void test() { 

    }

}

Code of default.partial.cs

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 : System.Web.UI.Page
{
    protected void Page_Load(object sender, 开发者_StackOverflowEventArgs e)
    {
        test();
    }
}

Update: if I add same namespace to both I get even weird message error I really don't understand partial class in asp.net whereas with winform I never encountered such problem !


How are you trying to access the method?

If calling from outside the class, it will never show up, as it is private.

The same will happen in derived classes.

Solution, make the method public or protected.


Add a namespace (the exact same one) to both class files that you define the partial _Default class and you will have access to what you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜