You can't use it like this. If I have understand correct you want to show something like notifications to the users and you don't want your page to be refreshed. The correct answer is that you can do it but it is not correct. Your code will look as a mess you will have a hidden field for the notification and so on. It depends of what you what you want to accomplish. For example:
I am using in my layout a global notification and my snipped looks like this
On the top of the layout just before the
I place an if statement that checks whether error message exists in the TempData
@if(TempData["error"])
{
// here you can visualize it well styled by some template for example
<div class="notification-error">@TempData[error]</div>
}
@if(TempData["success"])
{
// here you can visualize it well styled by some template for example
<div class="notification-error">@TempData[error]</div>
}
Then in your controller if you have something to say to the user you can
just do what you are doing like:
public ActionResult SomeAction(MyModel model)
{
if(something is not valid)
{
this.TempData["error"] user error
return this.View(model);
}
}
That case was if you need some server validation and proper message to the
user. After that option you have to set a script on your layout that removes
the error and success notifications if they exist on the page loads.
The other option if you need some modelstate validation on the client side you can take a look for js-unobtrusive validation that is driven by the viewmodel's attributes and it makes you automatic check on client side before it goes to the server.
The third option is if you need some other notification you can use a JS library called toastr. Examples library url It is light and very easy to use
Hope that this answer is explaining exactly what you need.