我是一个初学者,为什么在我的类和方法中看不到属性(id,类按钮,表),在代码中添加什么?
protected void Search_Click(object sender, EventArgs e)
{
SearchWordDocument searchword = new SearchWordDocument();
searchword.GetDocumentLibrary();
//See atribute SearchField
}
public class SearchWordDocument {
//Create array document
//Not see atribute SearchField
public void GetDocumentLibrary()
{
//Not see atribute SearchField }
答案 0 :(得分:3)
SearchWordDocument
类与ASP.NET页没有关系,因此您必须向其传递相关信息。
像这样:
protected void Search_Click(object sender, EventArgs e)
{
SearchWordDocument searchword = new SearchWordDocument();
var term = SearchField.Text;
searchword.GetDocumentLibrary(term);
}
public class SearchWordDocument
{
public void GetDocumentLibrary(string searchTerm)
{
// use searchTerm
}
}