.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

Why we are using ViewData and ViewBag?

Posted By :Daniel Bhagathsingh     Posted Date :December 27, 2013    Points :40   Category :.NET Framework 
ViewData and ViewBag are used to pass data from a controller to a view.

You can also find related Interview Question to Why we are using ViewData and ViewBag?  below: 

What's the difference between ViewData and ViewBag?

  
It uses the C# 4.0 dynamic feature. It achieves the same goal as viewdata and should be avoided in favor of using strongly typed view models (the same way as viewdata should be avoided).

So basically it replaces magic strings:

ViewData["foo"]
with magic properties:

ViewBag.Foo
for which you have no compile time safety (More...)

Which Kind of error provide by ViewData and ViewBag?

  
Run time error.It doesn't provide Compile time error. (More...)

Which command we are using to Retrieving data from ViewData?

  
string strData = ViewData["YourData"].ToString(); (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend