user1477388
user1477388

Reputation: 21430

MVC'ify WebForms Control

Currently, I am passing data from my codebehind into hidden fields like so:

Code behind: HiddenField statusValue.Value = progressPercent.ToString();

.ASCX page: <asp:HiddenField ID="statusValue" value="" runat="server" />

In MVC, I would pass a model from my controller to a view. Is there a similar way to do this in webforms? I am beginning to have a large number of hidden fields and it seems like a bad way to program this...

Upvotes: 0

Views: 98

Answers (1)

Cameron Tinker
Cameron Tinker

Reputation: 9789

Generally, having tons of hidden fields isn't the best practice. Have you looked into ASP.NET View State? It may achieve what you are looking for.
http://msdn.microsoft.com/en-us/library/bb386448(v=vs.100).aspx
http://msdn.microsoft.com/en-us/library/ms972976.aspx

Upvotes: 1

Related Questions