登陆验证的小控件,上面有两个输入框,分别用于输入用户名及密码,还有登陆及取消按钮,想知道怎么在使用这个控件的窗体上为用户名及密码赋值 public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private string name; public string Name1
{
get { return name; }
set { name =value; }
}
private string mm; public string Mm
{
get { return mm; }
set { mm =value; }
} private void button1_Click(object sender, EventArgs e)
{ if (fs(name,mm)==true)
MessageBox.Show("用户名密码匹配");
else
MessageBox.Show("用户名或密码错误");
}
private Boolean fs(string name,string mm) {
if (name == "1" && mm == "2")
{
return true;
}
else
{
return false; }
} private void button2_Click(object sender, EventArgs e)
{
this.textBox1.Text = "";
this.textBox2.Text = "";
}
{
public UserControl1()
{
InitializeComponent();
}
private string name; public string Name1
{
get { return name; }
set { name =value; }
}
private string mm; public string Mm
{
get { return mm; }
set { mm =value; }
} private void button1_Click(object sender, EventArgs e)
{ if (fs(name,mm)==true)
MessageBox.Show("用户名密码匹配");
else
MessageBox.Show("用户名或密码错误");
}
private Boolean fs(string name,string mm) {
if (name == "1" && mm == "2")
{
return true;
}
else
{
return false; }
} private void button2_Click(object sender, EventArgs e)
{
this.textBox1.Text = "";
this.textBox2.Text = "";
}
userControl11.Mm = "2";
这样写不会有错,可是我想要的是文本框中输入的内容
userControl11.Name1 = "1";
userControl11.Mm = "2";
就可以了
{
get{return txtUserName.Text;}
}
在b.aspx中 userControl.UserNameTextBox txt= (TextBox)YourUserControlID.FindControl("txtUserName");
string s = txt.Text;
{
public Form1()
{
InitializeComponent();
userControl11.Name1 ="1";
userControl11.Mm = "2";
}
}
if (fs(textBox1.Text ,textBox2.Text )==true)
MessageBox.Show("用户名密码匹配");
else
MessageBox.Show("用户名或密码错误");
}
private string name; public string Name1
{
get { return textBox1.Text; }
set { name =value;textBox1.Text=name; }
}
private string mm; public string Mm
{
get { return textBox2.Text; }
set { mm =value;textBox2.Text=mm; }
}