D
davidr
Hi,
I've researched this a lot and have a well understanding but still
can't get the darn textbox in the javascript.
I have a textbox that is set to runat="server" and I have a client
function for a comboBox when selectitemindexchanged happens it will
trigger. I know it goes into that because I did a alert("test"). Now
in there I want to take the item in the comboBox and put it in the
textbox that is runat="server". I know I have to use the
textbox.ClientID to get a reference to the textbox because its inside a
usercontrol.
So I am trying to do
var txtBox = document.getElementbyId("<%=textBox.ClientID%>").value;
or
var txtBox = document.getElementbyId("<%=txtBoxSnrInsp.ClientID%>");
alert(txtBox.ID)
to verify I have access to the textbox, but it never works. I've seen
many other examples on the net, but I feel I'm doing something wrong or
it isn't working. I know that since its in a usercontrol that the ID
is preappended with the usercontrol name that is why I must use
ClientID. Of course if I delete runat="server" then I can gain access
to the textbox, but I need that because when the user clicks save on
the usercontrol it will take the attributes in the textboxes and update
them to the database. Please anyone have any code example for this
scenario?
I've researched this a lot and have a well understanding but still
can't get the darn textbox in the javascript.
I have a textbox that is set to runat="server" and I have a client
function for a comboBox when selectitemindexchanged happens it will
trigger. I know it goes into that because I did a alert("test"). Now
in there I want to take the item in the comboBox and put it in the
textbox that is runat="server". I know I have to use the
textbox.ClientID to get a reference to the textbox because its inside a
usercontrol.
So I am trying to do
var txtBox = document.getElementbyId("<%=textBox.ClientID%>").value;
or
var txtBox = document.getElementbyId("<%=txtBoxSnrInsp.ClientID%>");
alert(txtBox.ID)
to verify I have access to the textbox, but it never works. I've seen
many other examples on the net, but I feel I'm doing something wrong or
it isn't working. I know that since its in a usercontrol that the ID
is preappended with the usercontrol name that is why I must use
ClientID. Of course if I delete runat="server" then I can gain access
to the textbox, but I need that because when the user clicks save on
the usercontrol it will take the attributes in the textboxes and update
them to the database. Please anyone have any code example for this
scenario?