Greeting,
I listed two examples of using style propriety for asp.net control.
what is the difference between the to examples?
my goal is to set the style and positions of asp.net controls in my page to be stable in firefox and IE browsers.
and should set the position as absolute or elative.
I have 30 asp.net controls in my page and I’m having problems with their positions.
please advice.
Example1:
<asp:TextBox ID="txtFirstName" runat="server"
Style="top: 198px; left: 421px;
position: relative; height: 23px; width: 144px">
</asp:TextBox>
Example2:
<style type="text/css">
.mystyle
{
position:relative;
top: 836px;
left: 662px;
height: -4px;
width: 128px;
}
</style>
<asp:TextBox ID="txtFirstName" runat="server"
CssClass="mystyle">
</asp:TextBox>
Apart from values
Example 1 is called
inline styleand Example 2 is calledcssstyle.The difference between two is
reusability, maintainability. You can use css style in multiple places and its easy to handle if their is any change in future.In your case as their are 30 controls if they contain same css then make a css class and assign them. otherwise use tables or inline one.
But better is to spend some time and do it with css which would be easy to handle for maintenance and is recommended too.