private bool CheckValidFile() { if ((fuImage.PostedFile != null) && (fuImage.PostedFile.ContentLength > 0)) { string[] validFileTypes = { "bmp", "gif", "png", "jpg", "jpeg" }; var ext = System.IO.Path.GetExtension(fuImage.PostedFile.FileName); var isValidFile = false; for (var i = 0; i < validFileTypes.Length; i++) { if (ext == "." + validFileTypes[i]) { isValidFile = true; break; } } if (!isValidFile) { var msg = "Invalid File. Please upload a File with extension " + string.Join(",", validFileTypes); msgbox.ShowError(msg); return(false); } else { return(true); } } else { return(true); } }
protected void btnSave_Click(object sender, EventArgs e) { try { int j = 0; foreach (GridViewRow gr in gvAllMenu.Rows) { HiddenField hdChildMenuID = (HiddenField)gr.FindControl("hdChildMenuID"); CheckBox chkTransfer = (CheckBox)gr.FindControl("chkMenu"); BL_MenuAssign st = new BL_MenuAssign(); if (chkTransfer.Checked) { st.EVENT = 'I'; st.ChildMenuID = int.Parse(hdChildMenuID.Value.ToString()); st.RoleID = Convert.ToInt32((string)ddlRoleName.SelectedValue.ToString()); st.MainMenuID = Convert.ToInt32((string)ddlMainMenu.SelectedValue.ToString()); int Id = 0; st.InsUpdDelMenuAssign(out Id); j++; } } if (j > 0) { msgbox.ShowInfo("Menu granted", 10, 400); FillGrid(); // Response.Redirect("~/Admin/MenuAssign.aspx"); } else { msgbox.ShowInfo("Please select child menu", 10, 400); } } catch (Exception ex) { msgbox.ShowError(ex.Message, 10, 400); } }