Not said that. However, you should specify in the Model of the view hopw many textboxes do you want. The view should create, either via direct code ( using a foreach),either with javascript
ok. I undestand the concept but Im in the need for something like the thing I asked because of the nature of the application. Its something very specific that I;m trying to do. So could anyone tell me how can I achieve it?
pantonis
Member
328 Points
260 Posts
ViewContext and HTML helpers
Jul 04, 2012 12:56 PM|LINK
From my class code I need to create html controls dynamically.
So I use the following
Viewcontext.Writer.Write("Html.TextBox('ClientName')");In my view the textbox is not created and I get Html.TextBox('ClientName') instead of the control.
Anyone knows how to do that?
Thanks
Please mark this post as answer if it helped you solve your problem
Sravan016
Member
14 Points
45 Posts
Re: ViewContext and HTML helpers
Jul 04, 2012 01:02 PM|LINK
You can give html control for input as @Html.TextBox("ClientName");
pantonis
Member
328 Points
260 Posts
Re: ViewContext and HTML helpers
Jul 04, 2012 01:07 PM|LINK
I have tried that but it does not work
Please mark this post as answer if it helped you solve your problem
Sravan016
Member
14 Points
45 Posts
Re: ViewContext and HTML helpers
Jul 04, 2012 01:08 PM|LINK
Is ClientName a model class or a property in model class
pantonis
Member
328 Points
260 Posts
Re: ViewContext and HTML helpers
Jul 04, 2012 01:09 PM|LINK
What has this to do. the problem is that is not rendered
Please mark this post as answer if it helped you solve your problem
ignatandrei
All-Star
135132 Points
21676 Posts
Moderator
MVP
Re: ViewContext and HTML helpers
Jul 04, 2012 01:11 PM|LINK
The controls should be created in the View, not in the Action. Pass the names or the count or... and create in the View!
pantonis
Member
328 Points
260 Posts
Re: ViewContext and HTML helpers
Jul 04, 2012 01:16 PM|LINK
So there is not any way to implement this?
Please mark this post as answer if it helped you solve your problem
CPrakash82
All-Star
18290 Points
2844 Posts
Re: ViewContext and HTML helpers
Jul 04, 2012 02:53 PM|LINK
There is a clear seperation between View and controller logic in MVC, why you want to do this? Your view logic should never go in controller.
Start thinking the way MVC works and not by webforms.
Thanks,
ignatandrei
All-Star
135132 Points
21676 Posts
Moderator
MVP
Re: ViewContext and HTML helpers
Jul 04, 2012 03:35 PM|LINK
Not said that. However, you should specify in the Model of the view hopw many textboxes do you want. The view should create, either via direct code ( using a foreach),either with javascript
pantonis
Member
328 Points
260 Posts
Re: ViewContext and HTML helpers
Jul 06, 2012 06:54 AM|LINK
ok. I undestand the concept but Im in the need for something like the thing I asked because of the nature of the application. Its something very specific that I;m trying to do. So could anyone tell me how can I achieve it?
Thanks in advance
Please mark this post as answer if it helped you solve your problem