我是菜鸟,我想让用户控件(ASCX)的某个属性←这个属性是我定义的,是公共PUBLIC的我定义了以后发现 右边的属性框里没有,想在这个控件HTML代码 里添加也没有。。但是可以在页面的PAGELOAD 事件里给这个控件的 这个属性赋值
=================================================================
问题是我想在 右边属性框 里给它赋值,或者在 HTML 这个控件的< >里给它的那个属性赋值怎么弄?谢谢大家
=================================================================
问题是我想在 右边属性框 里给它赋值,或者在 HTML 这个控件的< >里给它的那个属性赋值怎么弄?谢谢大家
public string MSG
{
get{return _msg;}
set{_msg=value;}
}你换成属性就OK,
右边属性框 可以给它赋值
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class Controls_UserManageControl : System.Web.UI.UserControl
{
//用户 增改查 控件,可以一件三用 2008 12 11
public string type = "请设定类型(新增,修改,查询)";
public string id = string.Empty;
public string destination = string.Empty;//转向地址 //private string sql;
protected void Page_Load(object sender, EventArgs e)
{
if (type == "新增")//增
{
lbl_Title.Text = "用户添加";
btn_submit.Text = "增加";
FormClear();
}
if (type == "修改")//改
{
lbl_Title.Text = "用户修改";
btn_submit.Text = "确认修改";
tbx_ID.Text = id;
tbx_ID.Enabled = false;
Customer cst = new Customer(id);
Response.Write("sadf"+cst.Name);
tbx_Name.Text = cst.Name;
//cst.Gender == true ? rb_Male.Checked =true: rb_Female.Checked=true;
if (cst.Gender == true)
{
rb_Male.Checked = true;
}
else
{
rb_Female.Checked = true;
}
tbx_Address.Text=cst.Address;
tbx_HomePhone.Text = cst.HomeTelephone;
tbx_CellPhone.Text = cst.CellPhone;
tbx_Yajin.Text = cst.MoneyYajinSum.ToString();
tbx_Score.Text=cst.Score.ToString();
ddl_Level.SelectedIndex = cst.Level - 1;
}
if (type == "查询")//查
{
lbl_Title.Text = "用户查询";
btn_submit.Text = "查询";
cbxIfID.Visible = true;
lbl_ID.Visible = false; }
}
protected void Button1_Click(object sender, EventArgs e)
{
Customer cst = new Customer();
cst.ID = tbx_ID.Text;
cst.Name = tbx_Name.Text;
cst.Gender = rb_Male.Checked ? true : false;
cst.Address = tbx_Address.Text;
cst.HomeTelephone = tbx_HomePhone.Text;
cst.CellPhone = tbx_CellPhone.Text;
cst.MoneyYajinSum =Convert.ToInt32(tbx_Yajin.Text) ;
cst.Score = Convert.ToInt32( tbx_Score.Text);
cst.Level = Convert.ToInt32(ddl_Level.SelectedValue); if (type == "新增")
{
//Response.Write(cst.Level);
bool result = manage.NewCustomerAdd2DB(cst);
if (result == true)//如果成功
{
Response.Write("<script>alert('新碟添加成功~');</script>");
FormClear();
}
}
if (type == "修改")
{
bool result = manage.UpdateCustomerAdd2DB(cst);
if (result == true)//如果成功
{
Response.Write("<script>alert('碟片信息更新成功~');</script>");
FormClear();
}
}
if (type == "查询")
{
Response.Redirect(destination+manage.GetStringGenerate(cst));
}
}
protected void cbxIfID_CheckedChanged(object sender, EventArgs e)
{
if (cbxIfID.Checked == true)//如果按照ID查询,其他的就没用了
{
tbx_ID.Visible = true;
tbx_Name.Visible = false;
rb_Male.Visible = false;
rb_Female.Visible = false;
tbx_Address.Visible = false;
tbx_HomePhone.Visible = false;
tbx_CellPhone.Visible = false;
ddl_Level.Visible = false;
tbx_Yajin.Visible = false;
tbx_Score.Visible = false;
} if (cbxIfID.Checked == false)
{
tbx_ID.Visible = false;
tbx_Name.Visible = true;
rb_Male.Visible = true;
rb_Female.Visible = true;
tbx_Address.Visible = true;
tbx_HomePhone.Visible = true;
tbx_CellPhone.Visible = true;
ddl_Level.Visible = true;
tbx_Yajin.Visible = true;
tbx_Score.Visible = true;
}
}
protected void btn_reset_Click(object sender, EventArgs e)
{
FormClear();
}
protected void FormClear()
{
rb_Male.Checked = true;
tbx_Score.Text = "0";
tbx_ID.Text = string.Empty;
tbx_Name.Text = string.Empty;
tbx_Address.Text = string.Empty;
tbx_HomePhone.Text = string.Empty;
tbx_CellPhone.Text = string.Empty;
ddl_Level.SelectedIndex = 0;
tbx_Yajin.Text = "0"; }
}