Ok then *ROLLS UP SLEEVES*
I think I understand what you are asking. Basically unless there is a character in the textbox the dropdownlist is not visible but when there is a character or one is added it becomes visible, however you want to do this client-side instead of having to postback after OnTextChanged - correct?
It really won't make any difference if you use TextBox and DropDownList controls or HTML controls - I'd use the Web Controls for the extra server-side functionality.
Your JavaScript function needs to change element ID for each TextBox/DropDownList pair as each row will have different client-side IDs.
As for linking your server controls to this JavaScript function I think you'll need to do the following:
1. Add the dynamic TextBox and DropDownList controls to the TableRow as you are doing.
2. Use the FindControl method of the TableRow to load the just created TextBox and DropDownList into local variables. (Sorry this is in C# but my VB.NET is crap)
Code:
TextBox tempTxt = (TextBox) tbrRow.FindControl("mark" + i.ToString)
3. You will then be able to access the ClientID property of the TextBox and DropDownList - these are the IDs that will be in the final generated HTML code.
4. You can use these ClientIDs to add a onblur event to the TextBox:
Code:
tempTxt.Attributes["onblur"] = String.Format("gohere('{0}','{1}')", tempTxt.ClientID, tempddl.ClientID);
You'll need to change you JavaScript function to use these two arguments:
Code:
function gohere(textboxID, dropdownlistID){
if (document.getElementById(textboxID).value == 'L')
{document.getElementById(dropdownlistID).style.display = 'none'}
else
{document.getElementById(dropdownlistID).style.display = ''}
}
That should cover it - let me know if something doesn't make sense.
Also:
How do I associate a style class to the input (held in a CSS file)?
I'm not sure if this was related or not but you just need to set the CssClass property e.g. if the textbox css class was called womble then:
Code:
tbcCell = New TableCell
Dim txtMarkBox As New System.Web.UI.HtmlControls.HtmlInputText
txtMarkBox.ID = "Mark" & i.ToString
txtMarkBox.EnableViewState = True
txtMarkBox.MaxLength = 1
txtMarkBox.CssClass = "womble"
tbcCell.Controls.Add(txtMarkBox)
tbrRow.Cells.Add(tbcCell)
HTH
DJ