当点击按钮然后显示消息

时间:2014-01-28 07:09:07

标签: html asp.net css

我有一个添加管理员帐户表单,当我添加帐户,然后我想显示消息“成功创建”当我点击按钮,这里当我调试我的项目和打开表单然后这个标签已经显示我如何删除它。

enter image description here

这里是css和html

<asp:Label ID="Lbe6" class="message success"  runat="server"></asp:Label> 

CSS

.message.success {
    border: 1px solid rgb(184, 201, 123);
    background: -moz-linear-gradient(center top , rgb(229, 237, 196), rgb(217, 228, 172)) repeat scroll 0% 0% transparent;
    color: rgb(63, 114, 39);
    text-shadow: 0px 1px 0px rgb(255, 255, 255);
}
.message {
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5) inset;
}

protected void Btn_SignUp_Click(object sender, EventArgs e)
        {
            try
            {

                c1.SignUp(nametxt.Value, passtxt.Value, Convert.ToInt32(DropDownList1.SelectedValue), Convert.ToInt32(DropDownList2.SelectedValue),Convert.ToInt32(DropDownList3.SelectedValue),mailtxt.Value,numbtxt.Value);
                //GridView1.DataSource=ca.viewadmin();
                 Lbe6.Text = (" Account Successfully Created");
                //  GridView1.DataBind();
            }
            catch
            {

               lbe5.Text = ("SIGNUP FAILED.PLEASE TRY AGAIN");

            }
            nametxt.Value = "";
            passtxt.Value = "";

            mailtxt.Value = "";
            numbtxt.Value = "";

        }

 protected void Page_Load(object sender, EventArgs e)
        {
 Lbe6.Visible = false;
}

3 个答案:

答案 0 :(得分:1)

请试试这个:

protected void Btn_SignUp_Click(object sender, EventArgs e)
{
  try
  {  c1.SignUp(nametxt.Value, passtxt.Value, Convert.ToInt32(DropDownList1.SelectedValue),     
 Convert.ToInt32(DropDownList2.SelectedValue),Convert.ToInt32(DropDownList3.SelectedValue),m      ailtxt.Value,numbtxt.Value);
                //GridView1.DataSource=ca.viewadmin();
                 Lbe6.Text = (" Account Successfully Created");
                //  GridView1.DataBind();
            }
            catch
            {

               lbe5.Text = ("SIGNUP FAILED.PLEASE TRY AGAIN");
               lbe5.Visible = true;

            }
            nametxt.Value = "";
            passtxt.Value = "";

            mailtxt.Value = "";
            numbtxt.Value = "";

}
protected void Page_Load(object sender, EventArgs e)
{
     Lbe6.Visible = false;
     Lbe5.Visible = false;
}

答案 1 :(得分:1)

试试这个

protected void Btn_SignUp_Click(object sender, EventArgs e)
        {//If not working properly set the visible attribute on button click also
            try
            {

                c1.SignUp(nametxt.Value, passtxt.Value, Convert.ToInt32(DropDownList1.SelectedValue), Convert.ToInt32(DropDownList2.SelectedValue),Convert.ToInt32(DropDownList3.SelectedValue),mailtxt.Value,numbtxt.Value);
                //GridView1.DataSource=ca.viewadmin();
                 Lbe6.Visible = true;
                 Lbe6.Text = (" Account Successfully Created");
                //  GridView1.DataBind();
            }
            catch
            {
               Lbe5.Visible = true;
               lbe5.Text = ("SIGNUP FAILED.PLEASE TRY AGAIN");

            }
            nametxt.Value = "";
            passtxt.Value = "";

            mailtxt.Value = "";
            numbtxt.Value = "";

        }

 protected void Page_Load(object sender, EventArgs e)
        {
 Lbe6.Visible = false;
Lbe5.Visible = false;
}

答案 2 :(得分:0)

如果您尝试隐藏标签,直到消息成功为真,请设置Lbe6.Visible = false,然后在设置消息成功时将其设置回Lbe6.Visible = true