Reputation: 41
Is it possible to put HTML5 controls inside a FormView Control in visual studios.
If so I can not figure out where I would put the bind attribute
<input name="name" type="text" id="idname" />
The formview creates a regular textbox which has a text attribute that I can then use the BIND expression to bind it to the datasource. Is this possible with the above code?
I am using Visual Studios 2010 but will upgrade to 2012 if I have too.
Upvotes: 2
Views: 284
Reputation: 6839
You can display data anywhere into the FormView using bee sting expression:
For Exemple, this line above will put the value from the DataSource into the input.
<input name="name" type="text" id="idname" value='<%# Eval("MyDataFieldName") %>'/>
Or
<input name="name" type="text" id="idname" value='<%# Bind("MyDataFieldName") %>'/>
But, using this way, you will miss all JavaScript security Validations, ViewState and lot of stuff provided for Server Controls to make things easyly to manage by the programmer.
Here's the documentation from MSDN to Data-Binding Expressions Overview.
Upvotes: 0
Reputation: 28387
You can use regular server-side control:
<asp:textbox id="idname" runat="server" value='<%# Bind("Property")%>' ></asp:textbox>
The control will be rendered as a plain html input element. You can use html5 attributes on it. So, it doesn't really matter. By specifying a valid <!DOCTYPE html>
on page will make it standard html5.
Upvotes: 1
Reputation: 3330
I think this will do -
<input name="name" type="text" id="idname" runat="server" value='<%# Bind("YourBindHere") %>' />
Upvotes: 1