I hope u will help me to find the answer. here i have one TextBox and one DropDown list ok. In this, Example: If i enter "Anu" in textbox, it should load it in dropdown list according to the textbox text. So how do i do? I am Using vb.net
-
You could call the keypress-event of the textbox and check for the keycode of 'Enter'. When pressed then add the value to the combobox?User999999– User9999992014-01-23 07:42:20 +00:00Commented Jan 23, 2014 at 7:42
-
Yes... its like that only... if i enter text like "Enter" it should load all like "Enter", "entff" in dropdown list.. related E letter.. @svrankenShu– Shu2014-01-23 07:50:31 +00:00Commented Jan 23, 2014 at 7:50
Add a comment
|
2 Answers
You can try this
<asp:TextBox ID="txtName" clientidmode="static" runat="server" onblur="AddItem();"></asp:TextBox>
<asp:DropDownList ID="ddlName" clientidmode="static" runat="server"></asp:DropDownList>
<script type="text/javascript">
function AddItem()
{
// Create an Option object
var opt = document.createElement("option");
// Add an Option object to Drop Down/List Box
document.getElementById("ddlName").options.add(opt);
// Assign text and value to Option object
opt.text = document.getElementById("txtName").value;
opt.value = document.getElementById("txtName").value;
}
</script>
3 Comments
Pawan
Edited Please check ow
Pawan
@Shu it should now as it is working on my end. Please share your code.
Shu
No its not working.....for example, if i enter c letter in text box i does't list all word which start with the letter c in dropdown list.. even i dint write any code in code behind for that.. @Pawan
Drag and drop a Dropdownlist onto your page, with a button beside it. Then double click the button and say:
Dropdownlist.Items.Add(Textbox1.Text);
PS: You'd better give us what you think about to avoid asking directly, because this will be misunderstood as homework.