首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

请问各大侠,怎么在一个类中访问aspx.cs文件中的linkbutton控件?

2012-03-25 
请教各大侠,如何在一个类中访问aspx.cs文件中的linkbutton控件?????aspx.cs文件如下using Systemusing Sy

请教各大侠,如何在一个类中访问aspx.cs文件中的linkbutton控件?????
aspx.cs文件如下
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using AjaxPro;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Drawing;

public partial class houseview : System.Web.UI.Page
{ public ArrayList btnphoto = new ArrayList(10);
 protected void Page_Load(object sender, EventArgs e)
  {
  btnphoto["linkbutton1"] = this.LinkButton1;
  btnphoto["linkbutton2"] = this.LinkButton2;
  btnphoto["linkbutton3"] = this.LinkButton3;
  btnphoto["linkbutton4"] = this.LinkButton4;
  btnphoto["linkbutton5"] = this.LinkButton5;
  btnphoto["linkbutton6"] = this.LinkButton6;
  btnphoto["linkbutton7"] = this.LinkButton7;
  btnphoto["linkbutton8"] = this.LinkButton8;
  btnphoto["linkbutton9"] = this.LinkButton9;
  btnphoto["linkbutton10"]=this.LinkButton10;
  }
}

我如何在我自己写的类中访问到 LinkButton
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;

/// <summary>
/// btnstatus 的摘要说明
/// </summary>
public class btnstatus
{
   
  public void setbtn1()
  {
  using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;

/// <summary>
/// btnstatus 的摘要说明
/// </summary>
public class btnstatus
{
  public ArrayList mybtn;
public btnstatus(ArrayList mybtn)
{
  mybtn = new ArrayList(10);
  this.mybtn = mybtn;
}

  public void setbtn1(System.Web.UI.WebControls.LinkButton btn1)
  {
  for (int i = 0; i < 7; i++) { (LinkButton)mybtn[i].text=i.tostring(); }//用这种方法无法访问?????????????????? }

}
  }

}





[解决办法]
直接传某个linkbutton过去吧

比如 test(LinkButton1,LinkButton2)


热点排行