How To Declare TextBox Different Ways In MVC

In this article i explain you how to declare textbox different ways in mvc
 1st Way:- textbox with name
         @Html.TextBox("txtName")
2nd Way :-textbox name and value
    @Html.TextBox("txtName","value")
3rd Way:-textbox name,value,id,maxlenth and size
    @Html.TextBox("txtName", "value", new { id="txt1",maxlenth="20",size="15"})
4th Way :-textbox name,value and currency 
    @Html.TextBox("txtName",15000,"{0:C}")

5th Way:-textbox name,value using dictionary 
    @Html.TextBox("txtName","value",new Dictionary<string,object>(){{"id","txt1"},{"maxlenth","15"},    {"size","20"},{"class","class1"}})

6th Way:-textbox name,value and styles
    @Html.TextBox("txtName", 12000, "{0:C}", new { style="color:green"})
7th Way :-textbox name,value and styles using dictionary
    @Html.TextBox("txtName", 15000, "{0:C}", new Dictionary<string, object>() { {"style","color:green"}})

No comments:

Post a Comment