468,505 Members | 1,569 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

How to access the controls that are inside of a DataList/DataGrid using JS?

My problem is simple, i have a datalist control with some controls inside of
EditTemplate (the problem is the same in the DataGrid). 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?

Thanks


Nov 18 '05 #1
0 1568

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Kaung Htut O via DotNetMonster.com | last post: by
1 post views Thread by Phil Townsend | last post: by
4 posts views Thread by jenn | last post: by
1 post views Thread by bill yeager | last post: by
reply views Thread by bill yeager | last post: by
1 post views Thread by bill yeager | last post: by
1 post views Thread by Mikkel Olsen | last post: by
6 posts views Thread by Davids | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
reply views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.