Ejemplo n.º 1
0
 protected void Binsert_Click(object sender, EventArgs e)
 {
     if (ValidateUserData() == true)
     {
         try
         {
             SqlDataSourceInsertUser.Insert();
             HttpContext.Current.Response.Write("<script>alert('Successfully Added user " + ins_Username.Text + "')</script>");
             ins_Username.Text       = "";
             ins_Password.Text       = "";
             passwdVerify.Text       = "";
             ins_Email.Text          = "";
             ins_FirstName.Text      = "";
             ins_LastName.Text       = "";
             ins_Mobile.Text         = "";
             ins_Address.Text        = "";
             ins_admin.SelectedValue = "N";
             ins_sex.SelectedValue   = "M";
         }
         catch
         {
             HttpContext.Current.Response.Write("<script>alert('Not able to Added user " + ins_Username.Text + "')</script>");
         }
     }
     else
     {
         HttpContext.Current.Response.Write("<script>alert('Invalid Inputs')</script>");
     }
 }
Ejemplo n.º 2
0
        protected void Binsert_Click(object sender, EventArgs e)
        {
            // performing validataion
            if (ValidateUserData() == true)
            {
                try
                {
                    // performing sql insert
                    SqlDataSourceInsertUser.Insert();
                    HttpContext.Current.Response.Write("<script>alert('Successfully Added user " + ins_Username.Text + "')</script>");

                    // clearing all the fields after successful insertion
                    ins_Username.Text       = "";
                    ins_Password.Text       = "";
                    passwdVerify.Text       = "";
                    ins_Email.Text          = "";
                    ins_FirstName.Text      = "";
                    ins_LastName.Text       = "";
                    ins_Mobile.Text         = "";
                    ins_Address.Text        = "";
                    ins_admin.SelectedValue = "N";
                    ins_sex.SelectedValue   = "M";
                }
                catch
                {
                    //Error in sql statement
                    HttpContext.Current.Response.Write("<script>alert('Not able to Added user " + ins_Username.Text + "')</script>");
                }
            }
            else
            {
                // error in input data
                HttpContext.Current.Response.Write("<script>alert('Invalid Inputs')</script>");
            }
        }