新手问问题 大家帮帮忙!
protected void CheckBox_Click(object sender, EventArgs e)
{
try
{
//获取角色和用户信息
CheckBox cbUserInRole = (CheckBox)sender;
string uname = cbUserInRole.ToolTip;
string rname = cbUserInRole.Attributes[ "role "];
//如果未被选中,则调用RemoveUserFromRole删除用户;否则调用AddUserToRole添加用户
if (!cbUserInRole.Checked)
{
Roles.RemoveUserFromRole(uname, rname);
}
else
{
Roles.AddUserToRole(uname, rname);
}
lbMessage.Text = "更新成功. ";
}
catch (System.Configuration.Provider.ProviderException ex)
{
//抛出异常
lbMessage.Text = ex.Message;
}
}
这是一个角色管理的代码
请问下这两句是什么意思?
string uname = cbUserInRole.ToolTip;
string rname = cbUserInRole.Attributes[ "role "];
------解决方案--------------------string uname = cbUserInRole.ToolTip;
是指:當鼠標停留在控件上時顯示的提示
string rname = cbUserInRole.Attributes[ "role "];
按字面上來看,應該是訪問一外名稱為role的屬性.但msdn上查不到checkBox有Attributes這個屬性