Web Part with ListBox TextBox and Button

Last post 02-07-2007 8:02 AM by jaloplo. 1 replies.

Sort Posts:

  • Web Part with ListBox TextBox and Button

    02-01-2007, 11:20 PM
    • Loading...
    • dglsmason
    • Joined on 09-08-2006, 7:18 PM
    • Posts 31

    I have a user control in a web part that contains an asp textbox, an asp button ('search button') and an asp listbox. I need to enable the user to do the following:

     

    1) when the user double-clicks on an item in the listbox, automatically copy the value of the selected item into the textbox, and perform the asp button's on-click, (as if they clicked the button to run C# code-behind), or can also just

    2) enter a value into the textbox and click on the button.

     

    The second one is easy, but I cannot seem to figure out how to do the first one. I can't seem to use javascript to copy the selected item's value to the textbox because the form is not in the web part (can't use document.forms[0].mytextbox.value). I know how to have the double-click on the listbox item call javascript, but don't know how to trigger the c# code-behind.

     

    Also, all of this includes MS Ajax 1.0 async processing (UpdatePanels, controls registered as async via ScriptManager). So, I need the double-click on the listbox item to not submit the whole page.

     

    Ideas?

     

  • Re: Web Part with ListBox TextBox and Button

    02-07-2007, 8:02 AM
    • Loading...
    • jaloplo
    • Joined on 06-23-2005, 6:58 AM
    • Alcala de Henares, Spain
    • Posts 254

    Hi,

    To solve the javascript of document.forms[0].mytextbox.value, you can do something like document.getElementById('TextBoxId').value. Be carefull and put the ClientID of the textbox and not the ID.

    For use with Ajax you can extends the ICallbackEventHandler interface for the ListBox control.

    Please mark the most helpful reply/replies as "Answer".

    My Blog
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter