Search code examples
c#asp.net-mvcwebformsasp.net-controls

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...


Solution

  • 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