Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm just started learning Bootstrap and ASP.Net MVC, a got little stuck.

This is my view:

@model Vrtic_2546.Models.Dogadjanja

@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Create</h2>


@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>Dogadjanja</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.KorisnikID, "KorisnikID", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("KorisnikID", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.KorisnikID, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.Naziv, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Naziv, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Naziv, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.Opis, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Opis, new { rows = "", cols = "", style = "width: 90%; height: 90px;" })
@Html.ValidationMessageFor(model => model.Opis, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.Datum, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Datum, new {htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Datum, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.Text, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Text, new { rows = "5", cols = "56", style = "" })
@Html.ValidationMessageFor(model => model.Text, "", new { @class = "text-danger" })
</div>
</div>
</div>

<div class="form-group">
<div class="col-lg-offset-2 col-md-10">
&lt;input type="submit" value="Create" class="btn btn-default" />
</div>
</div>

}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

And this is how it renders:
Picture

So, I need set up large "Text" textarea with text editor, a still keep it aligned from the left side.

What I have tried:

I tried few Bootstrap classes(col-lg10..etc), defined rows and columns, rows do get applied but columns don't. I'm not sure where is the problem is, can't grasp it, so any kind of help would be greatly appreciated.
Posted
Updated 1-Nov-16 9:49am
Comments
Richard Deeming 1-Nov-16 15:00pm    
Your screen-shot looks like a reasonable output. How did you want it to look?
1suli0 1-Nov-16 15:17pm    
I wanted "Text" taxtarea to be something like "Add your solution here" textarea here on CodeProject, bigger then other controls on Form. I'm trying, but...without sucsess.
Richard Deeming 1-Nov-16 15:23pm    
So you want it to be wider? Or taller? Or both?
1suli0 1-Nov-16 15:31pm    
Both, would be great.

1 solution

Making the <textarea> taller is simply a case of increasing the rows parameter.

As to making it wider: start by adding @class = "form-control" to the attributes. That will make it take up the full width of the parent element, as the other controls do:
HTML
<div class="form-group">
    @Html.LabelFor(model => model.Text, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.TextAreaFor(model => model.Text, new { rows = "10", cols = "56", @class = "form-control" })
        @Html.ValidationMessageFor(model => model.Text, "", new { @class = "text-danger" })
    </div>
</div>


Then, if you want it to fill the entire width of the row, you'll need to remove the col-* declarations, and move it outside of the form-horizontal container:
HTML
</div> <!-- form-horizontal -->
<div>
    <div class="form-group">
        @Html.LabelFor(model => model.Text, htmlAttributes: new { @class = "control-label" })
        <div>
            @Html.TextAreaFor(model => model.Text, new { rows = "10", cols = "56", @class = "form-control" })
            @Html.ValidationMessageFor(model => model.Text, "", new { @class = "text-danger" })
        </div>
    </div>
</div>
 
Share this answer
 

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