Solved

Mvc 3  : How to return a variable from a method  to an action result and dispay in view.

Posted on 2013-06-23
4
464 Views
Last Modified: 2013-06-25
I will like to pass a variable "totalCount" from a method to an ActionResult index view. I will like to show the variable in a text area in the view. How can I achieve this ? My code is attached.
I am using mvc 3
Question.txt
0
Comment
Question by:Sirdots
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Roopesh Reddy
Comment Utility
Hi,

You can try using ViewBag. Unfortunately, i'm not able to give you the code for it!

You can refer this article - http://rachelappel.com/when-to-use-viewbag-viewdata-or-tempdata-in-asp.net-mvc-3-applications

Hope it helps u...
0
 

Author Comment

by:Sirdots
Comment Utility
I've requested that this question be deleted for the following reason:

No good answer.
0
 
LVL 11

Accepted Solution

by:
Mihai Stancescu earned 500 total points
Comment Utility
Hi,

If you're using the code that you have attachet than you can get the totalCount in the Index() action and you can pass it to the model via ViewBag, create a custom viewmodel with that property in it and then in the view use the property like any other model bindings.



Regards,
Mishu
0
 

Author Comment

by:Sirdots
Comment Utility
Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now