You should place all your code in a controller instead of WebForms' code behind if you want to use MVC pattern.
My understanding is that the code behind still has use. Just be careful to limt your code behind to UI logic and leave any model retrieval and business logic in the controllers. It's perfectly fine IMHO to have code like this in the code behind:
dimi3
Member
318 Points
166 Posts
No Intellisense for ViewData in .aspx files
Dec 17, 2007 12:14 PM|LINK
I don't have Intellisense in .aspx files for ViewData although it's working.
Why?
vijayvrr_200...
Contributor
2341 Points
394 Posts
Re: No Intellisense for ViewData in .aspx files
Dec 17, 2007 12:31 PM|LINK
Hi
Not sure which edition of VS you are working with. Please see if http://forums.asp.net/t/1192768.aspx post helps.
VJ
subdigital
Contributor
2105 Points
445 Posts
ASPInsiders
Re: No Intellisense for ViewData in .aspx files
Dec 17, 2007 02:26 PM|LINK
Do you meant that no intellisense at all comes up? Or you only get the "object" members such as ToString() and GetHashCode() ?
To get strongly typed ViewData, your ViewPage needs to be ViewPage<T> (where T is the type that you want to consume on the page itself)
http://www.flux88.com
ASP.NET MVP
Certified ScrumMaster
ASPInsider
MCSD
dimi3
Member
318 Points
166 Posts
Re: No Intellisense for ViewData in .aspx files
Dec 17, 2007 02:36 PM|LINK
Thank you for your help. I think the last post gives me the answer.
I am currently using VS 2008 Standard Beta 2 and this should be the problem.
I know that my ViewPage needs to be ViewPage<T>. Anyway, thank you having taken time to answer me.
stribny
Member
87 Points
24 Posts
Re: No Intellisense for ViewData in .aspx files
Dec 22, 2007 05:56 PM|LINK
<% DateTime time = ViewData["Time"]; %>
<% time. - you should get help here %>
It works with every class/type, give it a shot!
dimi3
Member
318 Points
166 Posts
Re: No Intellisense for ViewData in .aspx files
Dec 24, 2007 06:55 AM|LINK
Thank you for your answer.
I tested the code you provided: it works. Why don't I have Intellisense for variables declared in Code Behind?
stribny
Member
87 Points
24 Posts
Re: No Intellisense for ViewData in .aspx files
Dec 24, 2007 11:44 AM|LINK
sergiopereir...
Member
227 Points
61 Posts
Re: No Intellisense for ViewData in .aspx files
Dec 24, 2007 04:03 PM|LINK
My understanding is that the code behind still has use. Just be careful to limt your code behind to UI logic and leave any model retrieval and business logic in the controllers. It's perfectly fine IMHO to have code like this in the code behind:
myRepeater.DataSource = ViewData["Products"];
myRepeater.DataBind();
Sergio Pereira
http://devlicio.us/blogs/sergio_pereira/