Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 20, 2008 08:43 AM by sjnaughton
Jul 15, 2008 07:10 AM|LINK
I need to add the * to all the required fields, e.g.
Name: * <input></input>
I wanna ask if there is any way to add it. Does dynamic data have any convenient way to get the required fields?
Because if I don't fill in those fields and click insert, the warning words will appear. So I guess there must be some ways to do it.
Jul 15, 2008 07:55 AM|LINK
<asp:TextBox id=TextBox1 runat=server
Jul 15, 2008 08:29 AM|LINK
I know this already.
But what I want needs to apply on all the dynamic fields generated, but not just a textbox.
Also, dynamic fields don't have the attribute id to refer to.
Jul 15, 2008 09:11 AM|LINK
The easiest way would be to edit ALL the FieldTemplates that you wanted the * to be able to appear by. in the FieldTemplate you could test for required fields and then show or hide the *.
I'll have a look to see if there is a way via IAutoFieldGenrator to do it as well.
Jul 15, 2008 11:01 PM|LINK
Here ho to do it (the easy way)
Add this to the Edit/Insert version of the FieldTemplate aspx file just after the main display field (usualy a
<span runat="server" ID="required" style="color:Red;" visible="false"> *</span>
And then in the code behind add if (Column.IsRequired) required.Visible = true; to the OnDataBinding event handler if one exists, otherwise create it.
protected override void OnDataBinding(EventArgs e)
required.Visible = true;
Hope this helps [:D]
Jul 16, 2008 12:59 AM|LINK
This is exactly what I want to do.
Thanks for your help.
Jul 16, 2008 11:11 AM|LINK
Thanks - that helped me also [:D]
Nov 20, 2008 05:38 AM|LINK
can u tell me that where does "Column" refers?
Actually I want to do exactly same thing what u hav told here.
And can u explain wat this line means
"Add this to the Edit/Insert version of the
FieldTemplate aspx file just after the main display field (usualy a
Thanks in Advance.
Nov 20, 2008 06:38 AM|LINK
In Dynamic Data all columns are displayed using field templates. You can find the templates in the \DynamicData\FieldTemplates directory. If you make a change to the RequiredFieldValidator in all of the templates in the directory you will get the consistent
change across all types of input in your application. Some of the field templates in the directory will have _Edit which are the edit versions of the templates, these are the ones you want to change.
Nov 20, 2008 08:43 AM|LINK
Hi Anukanasaha, Column is a property of the FiledTemplate that Dynamic Data uses to display a field. I recommend you look at some of the introductory vidoes on Dynamic Data here:
http://www.asp.net/learn/3.5-SP1/ and the first section
ASP.NET Dynamic Data this will give you an idea of what DD is about [:D]