Click to See Complete Forum and Search --> : How to access the controls that are inside of a DataList?


renateves
05-18-2004, 10:48 AM
My problem is simple, i have a datalist control with some controls inside of
EditTemplate. I want to have access to this controls, using javascript, but
i can't. How can i do this?


<Code>
<script language="javascript">
document.getElementById('<%=txt1.ClientID %>').value='test';
document.getElementById('<%=txt2.ClientID %>').value='test';
</script>
...

<asp: DataList id="Test" ...>
...
<EditItemTemplate>
<asp:textbox id="txt1" runat=server></asp:textbox>
</EditItemTemplate>
</asp: DataList>
...
<asp:textbox id="txt2" runat=server></asp:textbox>
</Code>


The first case, don't have success, but the second i can write to textbox.
The problem is that the client side ID of txt1 is "_ctl0:Test:_ctl0:txt1"
(different of txt2 ID ["_ctl0:txt2"]).

I have read this problem somewhere, but now i can't find it! :/
Can anyone help me?
Is Urgent.

Thanks