Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it bad to use runat="server" on <tr>?

I'm supporting an application that uses runat="server" all over the place to show/hide table rows.

For example, in places where there are dependent DropDownLists, the row with the child ddl will be hidden until a value us chosen in the parent ddl.

Is that a bad practice? Is there a better way to do this?

like image 376
Homer Avatar asked Jan 27 '11 18:01

Homer


3 Answers

I use runat="server" anytime I need it. So I think you can use it too. :-)

like image 96
Al Kepp Avatar answered Oct 18 '22 20:10

Al Kepp


I think that's absolutely terrible practice. First of all you do not need to make the trip to the server to hide and show controls, unless you need new data.

Second, any decent javascript framework will allow you to hide show controls based on the control's id, class name, or whatever css selector. Moreover using a javascript post/get to a generic handler will give you the data that you need without the postback.

I'd suggest using JQuery, or some other alternative.

like image 31
bleepzter Avatar answered Oct 18 '22 22:10

bleepzter


It depends on how much you care about performance. Anything that is marked with runat="server" goes through more processing than just client side tags.

Personally, I've used them before. Especially in the situation where a table cell or table row is relying on data from the server. You can use Javascript or JQuery with a hidden field but you still have to hit the server for the hidden field, so it doesn't buy much.

like image 5
Josh Avatar answered Oct 18 '22 22:10

Josh