gpt4 book ai didi

c# - 类和方法看不到属性asp

转载 作者:太空宇宙 更新时间:2023-11-03 22:36:35 24 4
gpt4 key购买 nike

我是初学者,为什么在我的class和methods中没有可见的属性(id,class button,table),要在代码中添加什么?

    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 }

最佳答案

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
}
}

关于c# - 类和方法看不到属性asp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54783835/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com