....</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.
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.
[:D]
Dynamic DataRequired Field
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
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.
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]
Dynamic DataFieldTemplates
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
longbcc112
Member
20 Points
35 Posts
How can I add red " * " to all the required fields?
Jul 15, 2008 07:10 AM|LINK
I need to add the * to all the required fields, e.g.
Name: * <input></input>
Age: <input>
Gender:* <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.
tompy_nation
Contributor
5054 Points
1268 Posts
Re: How can I add red " * " to all the required fields?
Jul 15, 2008 07:55 AM|LINK
<td>
<asp:TextBox id=TextBox1 runat=server />
</td>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator2"
ControlToValidate="TextBox1"
Display="Static"
Width="100%" runat=server>
*
</asp:RequiredFieldValidator>
longbcc112
Member
20 Points
35 Posts
Re: How can I add red " * " to all the required fields?
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.
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: How can I add red " * " to all the required fields?
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.
[:D]
Dynamic Data Required Field
Always seeking an elegant solution.
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: How can I add red " * " to all the required fields?
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 TextBox)
And then in the code behind add if (Column.IsRequired) required.Visible = true; to the OnDataBinding event handler if one exists, otherwise create it.
Hope this helps [:D]
Dynamic Data Required Field
Always seeking an elegant solution.
longbcc112
Member
20 Points
35 Posts
Re: How can I add red " * " to all the required fields?
Jul 16, 2008 12:59 AM|LINK
That's cool.
This is exactly what I want to do.
Thanks for your help.
dmeineck
Member
13 Points
29 Posts
Re: How can I add red " * " to all the required fields?
Jul 16, 2008 11:11 AM|LINK
@sjnaughton:
Thanks - that helped me also [:D]
http://www.meineck.net
anukanasaha
Member
23 Points
36 Posts
Re: How can I add red " * " to all the required fields?
Nov 20, 2008 05:38 AM|LINK
Hello sjnaughton
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 TextBox)"
Thanks in Advance.
scothu
Participant
1436 Points
291 Posts
Microsoft
Moderator
Re: How can I add red " * " to all the required fields?
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.
PM, ASP.NET Team, Microsoft
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: How can I add red " * " to all the required fields?
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]
Dynamic Data FieldTemplates
Always seeking an elegant solution.