protected void btnRegister_ServerClick(object sender, EventArgs e) { if (FileImgsave.HasFile) { lblmsg.Text = ""; var supportedTypes = new[] { "png", "jpg", "bmp", "jpeg", "tif", "eps", "jfif" }; var fileExt = System.IO.Path.GetExtension(FileImgsave.FileName).Substring(1); if (!supportedTypes.Contains(fileExt)) { lblmsg.ForeColor = Color.Red; lblmsg.Text = "File Extension Is InValid - Only Upload png,jpg,jpeg,bmp,tif,eps,jfif format images"; } else { string str = FileImgsave.FileName; FileImgsave.PostedFile.SaveAs(Server.MapPath("~/Images/" + "profile/" + str)); string imgPath = "images/" + "profile/" + str; string Query = "insert into tbl_Users(UserName,Badge,EnrollNo,Department,Year,Email,Password,Photo)Values('" + txtName.Value + "','" + Badge.Text + "','" + EnrollNo.Value + "','" + Department.Text + "','" + year.Text + "','" + txtEmail.Value + "','" + txtPassword.Value + "','" + imgPath + "')"; string ExistQ = "select * from tbl_Users where Email='" + txtEmail.Value + "'"; if (!ConnC.IsExist(ExistQ)) { if (ConnC.ExecuteQuery(Query)) { string CreateTableQuery = "create table if not exists groupsof_" + EnrollNo.Value + "(GroupID varchar(40))"; ConnC.ExecuteQuery(CreateTableQuery); if (Badge.Text == "Student" || Badge.Text == "CR") { string InsertGroupQuery = "insert into " + "groupsof_" + EnrollNo.Value + "(GroupID) values('" + year.Text + Department.Text + "')"; ConnC.ExecuteQuery(InsertGroupQuery); ConnC.AddToGroup(year.Text + Department.Text, EnrollNo.Value); } ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Congratulations!! You have successfully registered..');", true); FC.FireRegister(new SignalRChat.User() { name = txtName.Value, enrollno = EnrollNo.Value }); Response.Redirect("Login.aspx"); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Email is already Exists!! Please Try Different Email..');", true); } } } else { lblmsg.ForeColor = Color.Red; lblmsg.Text = "Please select Image"; } }