I need help on this following aspx code
aspx Code:
<asp:Label ID ='lblName' runat ='server' Text ='Name'></asp:Label> <asp:TextBox ID ='txtName' runat ='server'></asp:TextBox>
Consider this is my aspx page content. I am going to populate the values for the TextBox only after the postback from server. But the label is also posting to the server (runat='server') even though it’s not necessary. Should I write my code like this to save time from server with less load.
Corrected Code:
<label id ='lblNames'>Name</label> <asp:TextBox ID ='txtName' runat ='server'></asp:TextBox>
Only my server control will send to the server for postback and not my HTML control which has a static value.
Please suggest whether this is the correct way of coding.
If you take the
runat='server'out of the<label>element then it won’t be parsed as a server control. If you’re not going to do anything withlblNamesfrom the server then it is perfectly okay to leave it out.