0
votes

I'm trying to use ComboBox (http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ComboBox/ComboBox.aspx) in my ASP.NET application. Everything works fine, but I cannot set programmaticaly the value of combobox, which will by displayed when the page is loaded. The problem is that I want to set value, which isn't among the values in dropdown list - this is essential, I don't want to display this value in the dropdown list. I tried comboBox's 'Text', 'SelectedValue', 'SelectedText' properties, nothing works. I tried even find TextBox control in combobox and set its text - though this sets the text of the TextBox (can be seen in the page HTML source) but the text is not displayed (I gues some javascript code cause this).

If this isn't possible, my goal is to make a one-value hint (evaluated from data source) to textbox which will be displayed as dropdownlist (you can click on it and the value will be inserted in the textbox). So you can suggest me another solution.

Please help.

Thanks Uiii

1
Do you need to set text only or you want set default SelectedValue as well?Yuriy Rozhovetskiy
Just set text displayed in the ComboBox regardless of the content of the dropdown list.uiii

1 Answers

0
votes

Add protected string property Message in code-behind to Page's class and add this script on a page:

<script type="text/javascript">
    function pageLoad(sender, args) {
        //set text on initial load only
        if (args.get_isPartialLoad() == false) {
            $find("<%= ComboBox1.ClientID %>").get_textBoxControl().value = "<%= Message %>";
        }
    }
</script>

If you want to show static message you may scipt server-side Message property and just set static text as textbox value.