OK to use the same ID in each FormView template?

  • Thread starter Thread starter Cal Who
  • Start date Start date
C

Cal Who

I'm looking at someone else's code and it contains a FormView with a
InsertItemTemplate and a EditItemTemplate.

In each template there is a
<asp:TextBox ID="titleTextBox"...

element.



That is the same ID is in both templates. It appears to work OK

Is that OK.

Is it a good way to program?

What happens if I use FindControl? Does it find the active one?



Thank in advance for any info
 
Cal Who said:
I'm looking at someone else's code and it contains a FormView with a
InsertItemTemplate and a EditItemTemplate.

In each template there is a
<asp:TextBox ID="titleTextBox"...

element.



That is the same ID is in both templates. It appears to work OK

Is that OK.

Is it a good way to program?

What happens if I use FindControl? Does it find the active one?



Thank in advance for any info
yes.

It finds the id in html that's going to be emitted.
By definition, this is the "active" one.
 
Andy O'Neill said:
yes.

It finds the id in html that's going to be emitted.
By definition, this is the "active" one.

I take it that there is no advantage to using different IDs.


Thanks
 
Back
Top