| re: javascript for putting text in an asp.net edit control
Hi,
Read up about using IsClientScriptRegistered and RegisterClientScript - You
will need to use these otherwise you will have to hardcode the javascript
into the page, and that can cause issues if you start using user controls
and the like.
- You will need to create a function for the Client-Side onclick event of
the listbox
- You will also need to add an attribute to the listbox so that it
recognises the OnClick event
Use lstBox.Attributes.Add("OnClick", "lstBoxClickfunction()")
the javascript functoin would look something like the following
function lstBoxClickfunction(){
i = document.getElementById("lstBox").selectedIndex
document.getElementById("txtBox").value =
document.getElementById("lstBox").options[i].value
}
email me if there are any issues
"Michelle Stone" <mich_stone@yahoo.com> wrote in message
news:0a4601c39303$80b33900$a401280a@phx.gbl...[color=blue]
> I have a list box that I am populating (not via
> databinding) from some tables from my SQL database. I
> also have a TEXT BOX on the screen.
>
> I want to display whatever the user clicks on the list
> box on the edit box. I know I can do it by setting the
> AUTOPOSTBACK property of the list box to TRUE and by
> writing code to assign the .TEXT property of the edit box
> to the selected item in the list box. But I want to avoid
> the server round trip time.
>
> Can someone give me the javascript equivalent statement?
> I am new to javascript, so I would like to know the
> complete statement as I should put it in my code-behind
> (which is why i thought posting to this message to this
> newsgroup rather than a javascript newsgroup).
>
> Response.Write (something something something?)
>
> Thanks...[/color] |