哪位高手帮我看看这段代码啊?C#的简单登陆系统~

来源:百度知道 编辑:UC知道 时间:2024/06/19 10:39:56
哪位高手帮我看看这段代码啊?C#的简单登陆系统~
代码源如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace kechengbiao
{
public partial class Form1 : Form
{
string username = "123";
string password = "123";

public Form1()
{
InitializeComponent();
}

private void pictureBox1_Click(object sender, EventArgs e)
{

}

private void label1_Click(object sender, EventArgs e)
{

}

private void textboxUserName_TextChanged(object sender, EventArgs e)
{

}

private void ButtonOK_Click(object sender, EventArgs e)
{
if (u

textBoxUserName 应该是 textboxUserName

B要小写

textBoxPassword 应该是 textboxPassword

B要小写

C#对字母的大小写是敏感的,要注意.

textBoxUserName
你页面有没有这个textbox?
如果有的话..哎.那就是vs的问题了.我以前也有你这种情况.vs有时会有这种错误..
解决方法.再重新新建一个.aspx
然后把这个里面的代码和.aspx.cs里的代码一起拷贝进去..就OK了

我这里反正没错,你确定你的,TextBox的名称是这两个?“textBoxUserName”“textboxPassword”
请认真检查,如果真没错,新建个工程再试试吧。

if (username == textBoxUserName.Text && password == textBoxPassword.Text)
{
MessageBox.Show("登陆成功!");

}

textboxPassword文本框的ID你写错了,我估计你前面的ID也写错了,你到控件然后右键属性把它ID的值复制过来,然后粘贴到上面

private void label1_Click(object sender, EventArgs e)
private void pictureBox1_Click(object sender, EventArgs e)
private void textboxUserName_TextChanged(object sender, EventArgs e)
这三条是你双击该控件时自成的Click事件,要将它们删除,然后在调试窗口出错的那一条双击,会跳转到另一个程序,看见里面报错的那句代码(也是自动生出来的)删除即可。

50分啊!!!!
呵呵

if (username == textBoxUserName.Text && pa