如何显示具有不同功能的两个确认消息框 [英] How to show two confirmation message box with different functionality

查看:81
本文介绍了如何显示具有不同功能的两个确认消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我搜索很多,但我没有得到任何解决方案所以我想我应该问这里我的问题是完全不同我有一个网格视图,其中我有一个图像按钮删除部门



现在根据我的应用程序,当我创建部门时,将创建一个具有该部门名称的文件夹,并且在我的上传图像页面中,用户可以使用这些部门将图像保存在这些部门文件夹中以及它们的路径存储在数据库中。



上传图片page.cs



hi i search lot on this but i didn't get any solution so i thought i should ask here my question is quite different i have a grid-view in which i have an image button to delete department

Now according to my application when i create department a folder with that department name will create and in my upload images page user can user those department to save images in those department folder with and their path store in the database.

upload image page.cs

protected void btnSubmit_Click1(object sender, EventArgs e)
{
    string DepartmentID = ddlDepartment.SelectedValue;

    string Description = tbImageName.Text.Trim();

    string Priority = lblPriority.Text;
    //Get imagename from fileupload control
    string imgName = fileuploadimages.FileName.ToString();
    //sets the image path if exist then store image in that place else create new one
    string imgPath = "Images/Departments/" + "" + ddlDepartment.SelectedValue + "/";
    bool IsExists = System.IO.Directory.Exists(Server.MapPath(imgPath));
    if (!IsExists)
        System.IO.Directory.CreateDirectory(Server.MapPath(imgPath));
    //then save it to the Folder
    fileuploadimages.SaveAs(Server.MapPath(imgPath + imgName));
    //Open the database connection
    con.Open();
    //Query to insert * into images into database
    SqlCommand cmd = new SqlCommand("Insert into Images(ImageName,Description,Path,Priority,DepartmentID) values(@ImageName,@Description,@Path,@Priority,@DepartmentID)", con);
    //Passing parameters to query
    cmd.Parameters.AddWithValue("@ImageName", imgName);
    cmd.Parameters.AddWithValue("@Description", Description);
    cmd.Parameters.AddWithValue("@Path", imgPath + imgName);
    cmd.Parameters.AddWithValue("@Priority", Priority);
    cmd.Parameters.AddWithValue("@DepartmentID", DepartmentID);
    cmd.ExecuteNonQuery();
    //Close dbconnection
    con.Close();
    tbImageName.Text = string.Empty;
    Response.Redirect(Request.RawUrl);
}





n department_master页面



当用户点击时删除图像按钮确认消息框将出现询问是或否如果是,则部门从数据库中删除文件夹和图像现在该部分由我完成



for我使用的代码是department.aspx.cs:





n department_master page

When user click on delete image button a confirmation message box will appear to ask yes or no if yes then department delete from the database with folder and images now that part is done by me

for this code i used is department.aspx.cs:

protected void gvDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    string id = gvDetails.DataKeys[e.RowIndex].Values["DepartmentID"].ToString();
    con.Open();
    SqlCommand cmd = new SqlCommand("Select * from Department_Master where DepartmentID=" + id, con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);

    DataTable dt = ds.Tables[0];
    for (int i = 0; i < dt.Rows.Count; i++)
    {
        string imgPath = "Images/Departments/" + "" + dt.Rows[i]["DepartmentID"] + "/";
        bool IsExists = System.IO.Directory.Exists(Server.MapPath(imgPath));
        if (IsExists)
            System.IO.Directory.Delete(Server.MapPath(imgPath), true);
    }

    con.Close();


    con.Open();
    SqlCommand cmd1 = new SqlCommand("Delete from Images where DepartmentID=" + id + "; delete from Department_Master where DepartmentID=" + id, con);
    int result = cmd1.ExecuteNonQuery();
    con.Close();
    if (result == 1)
    {
        BindDetails();
        lblresult.ForeColor = Color.Red;
        lblresult.Text = id + " details deleted successfully";
    }
    BindDetails();
}

<asp:ImageButton ID="imgbtnDelete" CommandName="Delete" Text="Edit"  runat="server" ImageUrl="~/Images/delete.jpg" ToolTip="Delete" Height="20px" Width="20px"  önClientClick=" return confirm('Are you sure you want to delete');"/>





现在我想要的是当用户点击图片按钮时,消息框带有是或否以及当用户点击是去除e部门将出现另一个确认框,询问他们是否要保存这些图像,如果他们点击是,则向他们显示他们可以保存这些图像的选项,如果没有,则删除部门,文件夹和图像就像部门一样。 aspx.cs页面代码



now what i want is when user click on image button a message box comes with yes or no and when user click on yes to delete department another confirmation box will appear to ask whether they want to save those image or not and if they click on yes then show them the option where they can save those images and if no then delete department with folder and images just like the department.aspx.cs page code

推荐答案

此示例与您的要求类似:



This example is similar to what you require:

<pre lang="xml"><script type="text/javascript">
    function chk() {
        var x = window.confirm("Are you sure you are ok?")
        if (x) {
            
            var y = window.confirm("Really sure?")
            if (y)
                window.alert("Good!")
            else
                window.alert("Too bad")
        }
        else
            window.alert("Too bad")
    }
</script>





调用此函数:< br $>




Call this function on :

<input type="submit" value="sub1" onclick="chk();" />


试试以下文章。之后删除记录显示模式弹出如文章和是按钮删除图像。

http://www.aspdotnet-suresh.com/2011/12/ajax-yesno-button-options-customized.html [ ^ ]
Try following article.After deleting record show modal pop up as in article and on yes button delete images.
http://www.aspdotnet-suresh.com/2011/12/ajax-yesno-button-options-customized.html[^]


这篇关于如何显示具有不同功能的两个确认消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆