This is a migrated thread and some comments may be shown as answers.

Rad Confirm Message

10 Answers 272 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 10 May 2011, 05:47 AM
how i show the rad confirm messages in server side
please help me


Thanks,
Mohamed.

10 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 May 2011, 06:28 AM
Hello Mohamed,

Try the following approach. Hope this helps you.

C#:
protected void Button1_Click1(object sender, EventArgs e)
 {
   string radalertscript = "<script language='javascript'>function f(){ radconfirm('Are you sure ', confirmClearSingleCallBack, 400, 100) ; Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
   Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);
 }


Javascript:
function confirmClearSingleCallBack(args)
 {
 alert(args);
 

Also check the following KB article for more details.
Calling radalert from codebehind (all versions of RadWindow).

Thanks,
Princy.
0
mohamed
Top achievements
Rank 1
answered on 10 May 2011, 06:31 AM
Thanks for ur reply princy,
nothing happen
i'm using like that
it's one condition it's true message box come



SqlDataAdapter sqladp = new SqlDataAdapter();
            SqlConn = ObjDBHelp.GetOpenConnection();
            SqlCommand sqlcmd = new SqlCommand();
            DataTable dt1 = new DataTable();
            DataTable dt2 = new DataTable();

            if (e.CommandName == RadGrid.DeleteCommandName)
            {
                GridDataItem item = (GridDataItem)e.Item;
                string AssetID = item["AssetID"].Text;
                assignAssets(LoadAssets(AssetID));

                try
                {
                    string selectQuery = "select * from Tickets a , Assets b where a.Ticket_AssetID=b.AssetID and a.Ticket_AssetID = " + AssetID;
                    sqladp.SelectCommand = new SqlCommand(selectQuery, SqlConn);
                    sqladp.Fill(dt1);
                    int i = dt1.Rows.Count;
                    dt1 = null;

                    if (i > 0)
                    {
                        //string updateQuery = "UPDATE [Assets] SET Asset_Inactive=1 WHERE [AssetID] ='" + AssetID + "'";
                        //sqlcmd.CommandText = updateQuery;
                        //sqlcmd.Connection = SqlConn;
                        //sqlcmd.ExecuteNonQuery();
                        string radalertscript = "<script language='javascript'>function f(){ radconfirm('Are you sure ', confirmClearSingleCallBack, 400, 100) ; Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);
                        //RadAjaxManager1.Alert("This Asset Make Use Ticket, Are Sure Delete This Asset");
                    }
                    else
                    {
                        string deleteQuery1 = "DELETE FROM [Asset_Lease] WHERE [LeaseID] ='" + leaseid + "'";
                        sqlcmd.CommandText = deleteQuery1;
                        sqlcmd.Connection = SqlConn;
                        sqlcmd.ExecuteNonQuery();
                        string deleteQuery2 = "DELETE FROM [Asset_Service_Contracts] WHERE [Contract_AssetID] ='" + AssetID + "'";
                        sqlcmd.CommandText = deleteQuery2;
                        sqlcmd.Connection = SqlConn;
                        sqlcmd.ExecuteNonQuery();
                        string deleteQuery = "DELETE FROM [Assets] WHERE [AssetID] ='" + AssetID + "'";
                        sqlcmd.CommandText = deleteQuery;
                        sqlcmd.Connection = SqlConn;
                        sqlcmd.ExecuteNonQuery();
                    }

                    selectQuery = "SELECT a.AssetID,a.AssetName,a.SerialNumber,a.Asset_UserID,b.ppl_Name,a.Asset_Inactive FROM [Assets] a , People b " +
                                        "where a.Asset_UserID=b.PeopleID  order by AssetName asc";
                    sqladp.SelectCommand = new SqlCommand(selectQuery, SqlConn);
                    sqladp.Fill(dt2);
                    RadGrid1.DataSource = dt2;
                }
                catch (Exception ex)
                {
                    RadGrid1.Controls.Add(new LiteralControl("Unable to delete Id. Reason: " + ex.Message));
                    e.Canceled = true;
                }
            }


Thanks,
Mohamed.
0
Vasil
Telerik team
answered on 13 May 2011, 01:42 PM
Hi Mohamed,

The solution that Princy give you is pretty much what you need.

I am not sure if I quite understands you, because you said that nothing happens and in the same time message box is coming on top.

In your code what is expected to happen is that when you click on Delete button a post-back will happen. Then on the next page load on client side, you will see the confirm box. If you want to go back to the server and to perform some server operations you will need to make PostBack again. In confirmClearSingleCallBack you could fire delete command and then in server side to handle that command.

Regards,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
mohamed
Top achievements
Rank 1
answered on 13 May 2011, 02:11 PM
Thanks For Ur Reply.

i'm already applied princy reply like that .

after delete confirmation that come

i'm applied this on RadGrid1_ItemCommand
script's not fired .


how i fired this
FirePageCommand.
give some example

Thanks,
Mohamed.
0
Vasil
Telerik team
answered on 16 May 2011, 02:52 PM
Hi Mohamed,

Try to use the following approach.

ASPX:
<script type="text/javascript">
  function confirmClearSingleCallBack(args) {
    if (args == true) {
      var mtv = $find("<%=RadGrid1.ClientID %>").get_masterTableView();
      mtv.fireCommand("ConfirmDelete");
    }
  }
</script>
<div>
  <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
  </telerik:RadWindowManager>
  <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateDeleteColumn="True"  AllowAutomaticDeletes="true"  OnItemCommand="RadGrid1_ItemCommand">

CS:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "Delete")
    {
        Session["DeleteCandidateItem"] = e.Item;
 
        string radalertscript = "<script language='javascript'>function f(){ radconfirm('Are you sure ', confirmClearSingleCallBack, 400, 100) ; Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);
 
        e.Canceled = true;
    }
    else if (e.CommandName == "ConfirmDelete")
    {
        GridDataItem item = Session["DeleteCandidateItem"] as GridDataItem;
        if (item != null)
        {
            RadGrid1.MasterTableView.PerformDelete(item, false);
        }
    }
}

I am also attaching a full working example.

Kind regards,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
mohamed
Top achievements
Rank 1
answered on 16 May 2011, 03:09 PM
Thanks for ur reply.

not fired on that confirmClearSingleCallBack script


Thanks,
Mohamed.
0
Vasil
Telerik team
answered on 19 May 2011, 11:44 AM
Hi Mohamed,

I am not quite understanding your last reply.
Could you explain in more details what is the issue? Is there anything wrong with the execution of confirmClearSingleCallBack client function? Is there any JavaScript error when you open the page? Please debug the site using FireBug and let us know if some error appears into the console.
Did you tried to run the project that I attached in my last post?

Best wishes,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
mohamed
Top achievements
Rank 1
answered on 19 May 2011, 12:01 PM
That script not fired after in that function call

if (e.CommandName == "Delete")
    {
        Session["DeleteCandidateItem"] = e.Item;
 
        string radalertscript = "<script language='javascript'>function f(){ radconfirm('Are you sure ', confirmClearSingleCallBack, 400, 100) ; Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);
 
        e.Canceled = true;
    }
    else if (e.CommandName == "ConfirmDelete")
    {
        GridDataItem item = Session["DeleteCandidateItem"] as GridDataItem;
        if (item != null)
        {
            RadGrid1.MasterTableView.PerformDelete(item, false);
        }
    }


Thanks,
Mohamed.
0
Vasil
Telerik team
answered on 20 May 2011, 01:19 PM
Hello Mohamed,

Here is a video that I captured. It shows that the confirmation window is properly working.
http://screencast.com/t/I5EVvZ79ilK

Could you confirm that JavaScript is enabled in your browser?

All the best,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
mohamed
Top achievements
Rank 1
answered on 20 May 2011, 01:39 PM
Thanks for ur reply,

this kind confirm i did already .
but i want after that one confirmation come and go cilent side .
if the cilent side value = true
in i check in server side
if it's true i update something
bold one is next confirmation message

try
                {
                    string selectQuery = "select * from Tickets a , Assets b where a.Ticket_AssetID=b.AssetID and a.Ticket_AssetID = " + AssetID;
                    sqladp.SelectCommand = new SqlCommand(selectQuery, SqlConn);
                    sqladp.Fill(dt1);
                    int i = dt1.Rows.Count;
                    dt1 = null;

                    if (i > 0)
                    {

                        //string loadscript1 = "function f(){confirmCallBackFn()} Sys.Application.add_load(f);";
                        //ScriptManager.RegisterStartupScript(this, this.GetType(), "loadscript1", loadscript1, true);

                        ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "radconfirm('This Asset Make Use Ticket, Are Sure Delete This Asset?',confirmCallBackFn, 330, 100, null,'Send Message?');", true);


                        //string updateQuery = "UPDATE [Assets] SET Asset_Inactive=1 WHERE [AssetID] ='" + AssetID + "'";
                        //sqlcmd.CommandText = updateQuery;
                        //sqlcmd.Connection = SqlConn;
                        //sqlcmd.ExecuteNonQuery();                                 

                    }
                    else
                    {
                        SqlConn.Open();
                        string deleteQuery1 = "DELETE FROM [Asset_Lease] WHERE [LeaseID] ='" + leaseid + "'";
                        sqlcmd.CommandText = deleteQuery1;
                        sqlcmd.Connection = SqlConn;
                        sqlcmd.ExecuteNonQuery();
                        string deleteQuery2 = "DELETE FROM [Asset_Service_Contracts] WHERE [Contract_AssetID] ='" + AssetID + "'";
                        sqlcmd.CommandText = deleteQuery2;
                        sqlcmd.Connection = SqlConn;
                        sqlcmd.ExecuteNonQuery();
                        string deleteQuery = "DELETE FROM [Assets] WHERE [AssetID] ='" + AssetID + "'";
                        sqlcmd.CommandText = deleteQuery;
                        sqlcmd.Connection = SqlConn;
                        sqlcmd.ExecuteNonQuery();
                        SqlConn.Close();
                    }

                    selectQuery = "SELECT a.AssetID,a.AssetName,a.SerialNumber,a.Asset_UserID,b.ppl_Name,a.Asset_Inactive FROM [Assets] a , People b " +
                                  "where a.Asset_UserID=b.PeopleID  order by AssetName asc";
                    sqladp.SelectCommand = new SqlCommand(selectQuery, SqlConn);
                    sqladp.Fill(dt2);
                    RadGrid1.DataSource = dt2;
                }
                catch (Exception ex)
                {
                    RadGrid1.Controls.Add(new LiteralControl("Unable to delete Id. Reason: " + ex.Message));
                    e.Canceled = true;
                }

Thanks,
Mohamed.
Tags
Grid
Asked by
mohamed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
mohamed
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or