Reputation: 38228
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, EventArgs 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 !
Upvotes: 0
Views: 697
Reputation: 7539
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.
Upvotes: 1
Reputation: 117280
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
.
Upvotes: 1