Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my code

@Html.LabelFor(u => u.CompanyName)
@Html.TextBoxFor(u => u.CompanyName)
@Html.ValidationMessageFor(u => u.CompanyName)




@Html.LabelFor(u => u.Address1)
@Html.TextBoxFor(u => u.Address1)
@Html.ValidationMessageFor(u => u.Address1)




@Html.LabelFor(u => u.Adderss2)
@Html.TextBoxFor(u => u.Adderss2)
@Html.ValidationMessageFor(u => u.Adderss2)




@Html.LabelFor(u => u.City)
@Html.TextBoxFor(u => u.City)
@Html.ValidationMessageFor(u => u.City)




@Html.LabelFor(u => u.State)
@Html.TextBoxFor(u => u.State)
@Html.ValidationMessageFor(u => u.State)




@Html.LabelFor(u => u.Country)
@Html.TextBoxFor(u => u.Country)
@Html.ValidationMessageFor(u => u.Country)




@Html.LabelFor(u => u.ContactPerson)
@Html.TextBoxFor(u => u.ContactPerson)
@Html.ValidationMessageFor(u => u.ContactPerson)



Here labels and textboxs are not coming in proper order in mvc like (table format in asp.net) Based on their sizes they are adjusting side by side .. plz can u suggest me how we can adjust side by side all labels and textboxs in proper way
Posted

put code in div


@Html.LabelFor(u => u.CompanyName)
@Html.TextBoxFor(u => u.CompanyName)
@Html.ValidationMessageFor(u => u.CompanyName)

// rest of your code


XML
Finally add style tags in html page

<style>
    #alignform label {
        width: 300px; //adjust yourself according to contents
        display:inline-block;
    }
</style>
 
Share this answer
 
Hi Karthik,

Same Table tag is applicable in MVC also, you can use it like below
<-table>
<-tr>
<-td>
@Html.LabelFor(u => u.CompanyName)
<-/td>
<-td>
@Html.TextBoxFor(u => u.CompanyName)
@Html.ValidationMessageFor(u => u.CompanyName)
<-/td>
<-tr> ... <-/tr>
<-/table>

Just remove - in tag <-tagname>, added here since it will be automatically converted to html here.

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900