Click here to Skip to main content
14,922,492 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

My issue is , I am submitting page and getting error/success msg from db .I want to show error/success message on partial page. but it is showing on main page.

Please help

What I have tried:

my code :

Main View ClientInviteLetter :
@using(Html.BeginForm("SaveCustomerLetter", "Document", null, FormMethod.Post, new { id = "customerLetter", enctype = "multipart/form-data" }))


Partial View SaveCustomerDetailsPartialView:


@Html.TextBoxFor(model => model.ClientLetterDetails.DocumentUrl, new { id = "clientLetterUpload", type = "file", style = "background-color:White" })



public ActionResult SaveCustomerLetter(iVisa.UI.Entities.Model.Client customerViewModel, FormCollection frmCustomerLetterViewModel)

return RedirectToAction(ClientInviteLetter ,WebConstants.Document);
Updated 15-Feb-17 19:18pm

1 solution

//Controller- Action code :- 
this.SetNotification("your message form db", NotificationEnumeration.Success);
//define SetNotification method to store the error/success message
public void SetNotification(string message, NotificationEnumeration notifyType, bool autoHideNotification = true)
            this.TempData["Notification"] = message;
            this.TempData["NotificationAutoHide"] = (autoHideNotification) ? "true" : "false";
            switch (notifyType)
                case NotificationEnumeration.Success:
                    this.TempData["NotificationCSS"] = "<YourSuccessCssName>";
                case NotificationEnumeration.Error:
                    this.TempData["NotificationCSS"] = "<YourErrorCssName>";
                case NotificationEnumeration.Warning:
                    this.TempData["NotificationCSS"] = "<YourWarningCssName>";

//View :-
//Inside your form, create an empty div to show the message
<div id="NotificationBox" class="@TempData["NotificationCSS"]" style="height: 10px;text-align:center;color:green">
Singh Deepika 16-Feb-17 1:18am
//In the script tag of your view

@if (TempData["Notification"] != null)

$("#NotificationBox").delay(5000).queue(function (next) {
$("#NotificationBox").css("background-color", "");

manika123 17-Feb-17 0:33am
Thanks Deepika for your reply. but my issue is bit different. I want to show my message on partial view not on main of now it is showing on main view.

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