Html.Form returns a Form object (in our case we have two kinds - Simple and Mvc<>) and not a string, so using the "<%=" (which is sugar for Response.Write) outputs the tags AND the type.
Didn't see that the Dispose method of SimpleForm called WriteEndTag() and didn't think further about my <%= tag writing out the contents of the Form object.
Anyway, very well-written stuff you have there... [Yes]
Keep up the good work and thanks for the instant help! I do love MVC AND the toolkit...
robinvdb
0 Points
8 Posts
Html.Form extension writing out debug message?
Dec 11, 2007 10:18 AM|LINK
Hi,
I have created a page in which I use the following extension method of the HtmlHelper class:
<%= Html.Form("AddField", "Home", FormExtensions.FormMethod.post) %>This renders my <form> tag as:robinvdb
0 Points
8 Posts
Re: Html.Form extension writing out debug message?
Dec 11, 2007 11:12 AM|LINK
Digging a little deeper into Html.Form I found that there are two ways of using it:
<%= Html.Form("AddField", "Home") %> ... some other markup ... </form>robconery
Participant
852 Points
195 Posts
Re: Html.Form extension writing out debug message?
Dec 11, 2007 05:19 PM|LINK
Html.Form returns a Form object (in our case we have two kinds - Simple and Mvc<>) and not a string, so using the "<%=" (which is sugar for Response.Write) outputs the tags AND the type.
In this case you want to do one of two things:
<%using(Html.Form(...)){%>
<%}%>
or
<form action="<%=Url.Action("action","controller")%>">
robinvdb
0 Points
8 Posts
Re: Html.Form extension writing out debug message?
Dec 11, 2007 07:51 PM|LINK
Oh... my bad...
Thanks for the illuminating explanation!
Didn't see that the Dispose method of SimpleForm called WriteEndTag() and didn't think further about my <%= tag writing out the contents of the Form object.
Anyway, very well-written stuff you have there... [Yes]
Keep up the good work and thanks for the instant help! I do love MVC AND the toolkit...
Robin
robconery
Participant
852 Points
195 Posts
Re: Html.Form extension writing out debug message?
Dec 11, 2007 07:53 PM|LINK
Thanks Robin :)