当前位置:编程学习 > C#/ASP.NET >>

求ASP.NET高手帮忙

各位高手帮忙解释下每行代码的意思。感谢!!!!
添加管理员:

public partial class Manger_MemberAdd : System.Web.UI.Page
{
    MangerClass mc = new MangerClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["AID"]) == "")
        {
            Response.Redirect("Fail.aspx");
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        txtName.Text = "";
        txtPass.Text = "";
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtName.Text == "")
        {
            Response.Write("<script>alert('请输入管理员名!');location='javascript:history.go(-1)';</script>");
        }
        else
        {
            int P_Int_returnValue = mc.AddAdmin(txtName.Text.Trim(),txtPass.Text.Trim());
            if (P_Int_returnValue==100)
            {
                Response.Write("<script>alert('该管理员名已存在!');location='javascript:history.go(-1)';</script>");
            }
            else
            {
                Response.Write("<script>alert('添加成功!');location='javascript:history.go(-1)';</script>");
           
            }
       
        }
    }
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        bool result = mc.CheckA(txtName.Text);
        if (result == true)
        {
            lblResult.Text = "该用户已存在";
        }
        else {
            lblResult.Text = "不存在该用户";
        }
    }
}

答案:

public partial class Manger_MemberAdd : System.Web.UI.Page
{
    MangerClass mc = new MangerClass(); 建立一个管理员类对象mc
    protected void Page_Load(object sender, EventArgs e)  页面加载时
    {
        if (Convert.ToString(Session["AID"]) == "")  如果Session对象的 AID为空
        {
            Response.Redirect("Fail.aspx");  就跳转到 Fail.aspx 失败这个页面
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)  单击取消
    {
        txtName.Text = "";   用户名为空
        txtPass.Text = "";  密码为空
    }
    protected void btnSave_Click(object sender, EventArgs e)  保存按钮
    {
        if (txtName.Text == "")  如果用用户名为空
        {
            Response.Write("<script>alert('请输入管理员名!');location='javascript:history.go(-1)';</script>");
        }  提示请输入用户名,并执行后退动作
        else 
        {
            int P_Int_returnValue = mc.AddAdmin(txtName.Text.Trim(),txtPass.Text.Trim());  把管理员用户名密码加入
            if (P_Int_returnValue==100)  如果返回100 说明已经存在
            {
                Response.Write("<script>alert('该管理员名已存在!');location='javascript:history.go(-1)';</script>");  提示并后退
            }
            else  如果不是100就是成功了
            {
                Response.Write("<script>alert('添加成功!');location='javascript:history.go(-1)';</script>");
              提示成功,并后退前一页面
            }
       
        }
    }
    protected void btnCheck_Click(object sender, EventArgs e)  检查用户名
    { 
        bool result = mc.CheckA(txtName.Text);  调用mc对象进行检查
        if (result == true)  如果返回true
        {
            lblResult.Text = "该用户已存在";  提示存在
        }
        else {
            lblResult.Text = "不存在该用户";  提示不存在
        }
    }
}

每一行,每一行的解释,想累死哥呀,

大概给你讲一下,第一行定义一个公共类。尔后定义三个函数,分别是判断缓存,初始化变量,传递变量到JS,应该有个包含文件吧,

上一个:会asp.net的进
下一个:ASP.NET程序问题6

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,