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:blush:rders runat="server" id="order1"></CustomListBox:blush: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

Top