Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

What is a best practices process in handling a large number of Textbox TextChanged events in codebehind?

$
0
0

I tend to group TextChanged events like this as an example.  

protected void TextChangedEvents(object sender, EventArgs e) { 
                    if (sender == txt1) {
                        string strTest1 = txt1.Text));
                    }
                    else if (sender == txt2) {
                        string strTest2 = txt2.Text));
                    }
}

If I don't have very many on a form, I use the standard procedure as follows:
 protected void txt1_TextChanged(object sender, EventArgs e)  { 
                string strTest1 = txt1.Text;
}

In the first one where they are combined, I just show a very simple example. If the subroutine is complex anda lot of repetitions, it saves on the size of the code behind file. But is it an ok way to do it. It seems theoretically that having an individual procedure for each control would end up being faster, but the file would be smaller. I assume it would be negligible but am curious as to what others think.



Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>