views:

19

answers:

1

Hey, Easy question for ASP.NET profenssionals: I have a few dynamic generated textboxes in a row. In this row is also a image with an eventhandler "onclick". I will create a relationship between the textbox and the image. I click on the image, choose a value and then the textbox will be filled.

Currently my controls have following dynamic generated ID's:

Button:

ct100_cph_Detail_rpFields_ct109_rpCell_ct100_cbf_bed1_item_sym

Textbox

ct100_cph_Detail_rpFields_ct109_rpCell_ct100_tb_bed1

This two controls must be in a relationship. The best solution for me is with JavaScript, because I have not much ASP.NET skills..

Thanks for help ! :-)

A: 

If the generated IDs always follow this scheme, you can access the textbox by getting the ID of the button/image, and replace the none-unique part inside this ID (_cbf_bed1_item_sym) with the none-unique part of the textbox-ID(_tb_bed1)

Example:

<input type="button"  value="click" 
   id="ct100_cph_Detail_rpFields_ct109_rpCell_ct100_cbf_bed1_item_sym" 
   onclick="document.getElementById(this.id.replace(/_cbf_bed1_item_sym$/,'_tb_bed1')).value='gotcha'"/>

<input type="text" 
   id="ct100_cph_Detail_rpFields_ct109_rpCell_ct100_tb_bed1"/>

There may be other ways, but to say anything about them you have to show the markup of such a row(needed to see what's the relation of these elements regarding to their position inside the document-tree)

Dr.Molle