Similar to the Cascading WebDropDown value
http://samples.infragistics.com/2010.1/WebFeatureBrowser/Default.aspx
How do you set a textbox value after the user selects a value of a dropdown (without doing a postback)
I have a list of usernames in a dropdownlist. When a name is selected I want to fire a server side event to lookup the phonebook from an arraylist depending on name selected and return that phone number to a WebTextEditor (or textbox)
On the cascading sample there is javascript
combo2.loadItems(eventArgs.getNewSelection()[0].get_text());
that calls the server side event
WebDropDown2.ItemsRequested +=
new DropDownItemsRequestedEventHandler
(WebDropDown2_ItemsRequested);
var text1 = $find('<%= WebTextEditor1.ClientID %>');
text1.set_text(???????????)
Hi,
I am not sure i understand the scenario completely, but in order to set the current text in the dropdown on the client-side you can do the following:
var dropDown = $find('<%= WebDropDown1.ClientID %>');
dropDown.set_currentValue('some value in the input', true);
Usually, if you select an item, the input value should get updated automatically.
Let me know if that helps
Thanks, Angel
I want to set the value of the textbox from a value in the code behind page (which is generated after the dropdown is changed.)
1. Dropdown changed
2. Grab a value from the codebehind page.
3. Change textbox value (without postback)
Sorry, I should I typed Postback instead of Page refresh. (I realize you have to Postback to get the value from the server.)
E.g. How do you do the above without causing the user's Page to Refresh
you can't avoid a postback using the method you want to use. I don't know how else you can fire a server event without a postback.
If someone selects a username, then going to server to fetch a phone number requires a postback. How else would you get to the data?
You should use the WebDropDown.ValueChanged event to fetch your data and assign it to the text box.
If you, for some reason, can't or don't know how to handle the complete post back then you might want to do an async postback, using the update panel.
Vb.code sample...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
'load your dropdown here..
end if
Private Sub WebDropDown1_ValueChanged(ByVal sender As Object, ByVal e As Infragistics.Web.UI.ListControls.DropDownValueChangedEventArgs) Handles WebDropDown1.ValueChanged
'take the selectedItem or selectedvalue or key and go fetch your phone number, return a value from your arraylist.
textbox1.text= valuereturned from above..
End Sub