Id of my control

S

simon

I have my user control and inside that control I have textBox:

<asp:TextBox Runat=server AutoPostBack=True ID=txtListBox
onkeydown="filter()"></asp:TextBox>
<script language="vbscript">
sub filter
msgbox document.getElementById("txtListBox").value
end sub
</script>
The id of my textBox is txtListBox.

Than I use my control on the page:

<%@ Register TagPrefix ="CustomListBox" TagName = "orders" Src =
"userControls\customListBox.ascx"%>
<CustomListBox:eek:rders runat="server" id="order1"></CustomListBox:eek:rders>

and when the page is rendered I get input box:

<input name="order1:txtListBox" type="text"
onchange="__doPostBack('order1$txtListBox','')" language="javascript"
id="order1_txtListBox" onkeydown="filter()" />

The id of this input is not "txtListBox" but "order1_txtListBox" so my
script won't work.

How can I solve this problem?

Thank you,
Simon
 
R

Raterus

I may be wrong, but could you pass the filter sub a reference to the control calling it. I've done it in javascript before, I guess you could do it in vbscript as well. do something like this:

....onkeydown="filter(this)" or in vbscript it may be "filter(me)"

sub filter(control)
msgbox control.value
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top