Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am facing problem for returning message from controller not showing on same page is redirected to other page

My Code for view :
SQL
@using (Ajax.BeginForm("Components", "Controller", new AjaxOptions
                      {
                          HttpMethod = "POST",
                          OnFailure = "ShowError()",
                          UpdateTargetId = "ShowSuccess()"
                      }))


And Code For Script :
C#
function ShowError() {


        $("#status").addClass("alert alert-error");      $("#status").removeClass();
        $("#status").html("<strong>Error!</strong> There was an error posting the contact form. Please try again later.");
    }

    function ShowSuccess() {

        $("#target").removeClass();
        $("#target").addClass("alert alert-success");
    }


Code For Controller :
SQL
[HttpPost]
        public ActionResult Components(model objModel)
        {
            try
            {
                 // 
            }
        }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900