Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
472 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
ID: 39272272
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
ID: 39274294
I've requested that this question be deleted for the following reason:

No good answer.
0
 
LVL 11

Accepted Solution

by:
Mihai Stancescu earned 2000 total points
ID: 39273807
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
ID: 39274296
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

927 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