hi there
i'm a begginer in c#
i need to create a textbox onkeypress..
i have a dynamic list of courses...
i need the first charachters that typed in the textbox will find those courses with names that begins with those charachters ...kind of filter...
and i need to do that on server side..not with javascript..
is this possible? and how can i do that...
this is a web application ..
thanks to all answers...
pleaase show me how to do this in syntax...on client and server...

Recommended Answers

All 2 Replies

I'm working on something

I first make a list.
when the text change in the textbox then I will check if the chars are the same.
To check if it works I print all the possible strings in a listBox.
I hope that you can use this, if you can vote than aub!

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        List<string> dinosaurs;
        List<string> dinosaurs2;

        public Form1()
        {
            InitializeComponent();
            string[] input = { "Brachiosaurus", 
                                "Bqachiosaurus",
                           "Amargasaurus", 
                           "Mamenchisaurus",
                           "Joeri"};

          dinosaurs = new List<string>(input);

        }

        private void txt_write_TextChanged(object sender, EventArgs e)
        {
            dinosaurs2 = new List<string>();
                for (int x = 0; x < dinosaurs.Count; x++)
                {
                    if (dinosaurs[x].Substring(0, txt_write.Text.Length) == txt_write.Text.Substring(0, txt_write.Text.Length))
                    {
                        dinosaurs2.Add(dinosaurs[x]);
                    }
                }

          listBox1.DataSource = dinosaurs2;
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.