2016-04-14 8 views
2

Ist es möglich, einem Html.BeginForm Stilattribute hinzuzufügen?Hinzufügen eines Stilattributs zu Html.BeginForm MVC/C#

Etwas wie:

@using (Html.BeginForm("Action","Controller", FormMethod.Post, new {@class="myClass"}, new {@style="margin-right:100px margin-top:50px"})) 
{ 
} 
+0

Mögliche Duplikate von [Hinzufügen von CSS-Klasse zu Html.BeginForm()] (http://StackOverflow.com/questions/13984029/Adding-Css-Class-to-HTML-Beginnform) –

Antwort

3

versuchen

@using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { style = "margin-right:100px; margin-top:50px", @class = "myClass" })) 
{ 

} 
+0

Immer erklären Sie Code, was Sie sind geben. Vielen Dank. –

0

Schauen Sie hier:

StackOverflow Link

Another StackOverflow Link

Ich bin kein t MVC-Experte, aber laut beigefügten Links Ihr Code sollte so aussehen:

@using (Html.BeginForm("Action","Controller", FormMethod.Post, new {@class="myClass"}, new {style="margin-right:100px margin-top:50px"})) 
{ 
} 

Hoffe, das hilft. :)

2
//Try this format 
@using (Html.BeginForm("Action", "Controller", null,FormMethod.Post, new { @style = "your styles ",@class = "your classname"})) 
{ 

} 
1

@using (Html.BeginForm("Index", "Home", null, FormMethod.Post, new { style = "margin-right:100px;margin-top:50px;border:1px solid red;", @class = "thFormClass" })) 
 
{ 
 

 
}

dieses Probieren Sie es funktionieren wird.

Verwandte Themen