By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,083 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,083 IT Pros & Developers. It's quick & easy.

Id of my control

P: n/a
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:orders runat="server" id="order1"></CustomListBox:orders>

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
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"simon" <si*********@stud-moderna.si> wrote in message news:%2***************@TK2MSFTNGP11.phx.gbl...
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:orders runat="server" id="order1"></CustomListBox:orders>

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

Nov 18 '05 #2

P: n/a
One solution is to output your script dynamically from server side code and
use txtListBox.ClientID to determine what the ID is at runtime.

You might find the RegisterClientScriptBlock method useful:
http://msdn.microsoft.com/library/de...BlockTopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"simon" <si*********@stud-moderna.si> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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:orders runat="server" id="order1"></CustomListBox:orders>

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

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.