Value in a alertbox
I have some value in controller ,i need to display that value in alert box.could you please tell me how to do that
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sunny SharmaRank #223 · 11.1K reputationPosted Oct 24, 2013, 3:53 AM EDT
-----------------------------------------
Sunny SharmaRank #223 · 11.1K reputationPosted Oct 24, 2013, 1:49 AM EDT
Keeping it simple, add the value to ViewBag use it in View, like:
Controller
-----------------
....
ViewBag.myValue = 45;// set your value here.
....
-----------------
View
-----------------
-----------------
Simple as that.
HTH :)
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 24, 2013, 3:17 AM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 24, 2013, 3:22 AM EDT
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 24, 2013, 3:30 AM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Oct 24, 2013, 3:31 AM EDT
Show me your View and controller.
@ Jaganathan Bantheswaran: ViewBag will also work, TempData is a kind of temporary container which is emptied after the value is read.
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 24, 2013, 3:35 AM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Oct 24, 2013, 3:39 AM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 24, 2013, 3:40 AM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Oct 24, 2013, 3:45 AM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Oct 24, 2013, 3:49 AM EDT
Robbinson86 reputationPosted Oct 24, 2013, 3:49 AM EDT
The one of the easiest way to achieve this is to return value from controller using ViewData.
For example:
In your view, you can write in script block.
Another way to achieve the same is directly response the script from your controller.
public ActionResult UploadPropertyImage()
{
// Business logic....
return Content("");
}
Hope, this will help you out.
Please Don't forget to mark as answer if this post helps you.
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 24, 2013, 3:53 AM EDT
Its not better approach to have all the values in ViewBag, use your own model/viewmodel instead of ViewBag.
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 24, 2013, 3:58 AM EDT
In alet u r displaying message,along with that i want to display some value.can u tell me that
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 24, 2013, 3:59 AM EDT
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 24, 2013, 4:02 AM EDT
Vinoth Kumar9 reputationPosted Oct 24, 2013, 5:03 AM EDT
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 24, 2013, 5:13 AM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 27, 2013, 10:28 PM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 28, 2013, 2:03 AM EDT
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 28, 2013, 9:17 PM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 29, 2013, 8:40 PM EDT
You cant, just leave it.
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 30, 2013, 3:38 AM EDT
That was working fine, thank u.
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 30, 2013, 3:39 AM EDT