首页 新闻 赞助 找找看

用HtmlHelper怎么写?

0
悬赏园豆:10 [待解决问题]

<input name="textfield2" type="text" class="input-text" id="textfield" style="color:#999" onfocus="if(value==defaultValue){value='';this.style.color='#000'}" onblur="if(!value){value=defaultValue; this.style.color='#999'}" size="60">

 

 

请问这个换成MVC的htmlHelper怎么写,本人对MVC不熟,请多多指教

起早抹黑的程序猿的主页 起早抹黑的程序猿 | 初学一级 | 园豆:126
提问于:2018-03-14 11:51
< >
分享
所有回答(2)
0

HtmlHelper用来在视图中呈现 HTML 控件。

以下列表显示了当前可用的一些 HTML 帮助器。 本主题演示所列出的带有星号 (*) 的帮助器。

 

  • ActionLink — Links to an action method." style="margin: 0px; padding: 0px;">ActionLink - 链接到操作方法。

  • BeginForm * — Marks the start of a form and links to the action method that renders the form." style="margin: 0px; padding: 0px;">BeginForm * - 标记窗体的开头并链接到呈现该窗体的操作方法。

  • CheckBox * — Renders a check box." style="margin: 0px; padding: 0px;">CheckBox * - 呈现复选框。

  • DropDownList * — Renders a drop-down list." style="margin: 0px; padding: 0px;">DropDownList * - 呈现下拉列表。

  • Hidden — Embeds information in the form that is not rendered for the user to see." style="margin: 0px; padding: 0px;">Hidden - 在窗体中嵌入未呈现的信息以供用户查看。

  • ListBox — Renders a list box." style="margin: 0px; padding: 0px;">ListBox * - 呈现列表框。

  • Password — Renders a text box for entering a password." style="margin: 0px; padding: 0px;">Password - 呈现用于输入密码的文本框。

  • RadioButton * — Renders a radio button." style="margin: 0px; padding: 0px;">RadioButton * - 呈现单选按钮。

  • TextArea — Renders a text area (multi-line text box)." style="margin: 0px; padding: 0px;">TextArea - 呈现文本区域(多行文本框)。

  • TextBox * — Renders a text box." style="margin: 0px; padding: 0px;">TextBox * - 呈现文本框

TextBox * — Renders a text box." style="margin: 0px; padding: 0px;"> 

TextBox * — Renders a text box." style="margin: 0px; padding: 0px;">1.ActionLink

复制代码
@Html.ActionLink("这是一个连接", "Index", "Home") 带有QueryString的写法 @Html.ActionLink("这是一个连接", "Index", "Home", new { page=1 },null) @Html.ActionLink("这是一个连接", "Index", new { page=1 }) 有其它Html属性的写法 @Html.ActionLink("这是一个连接", "Index", "Home", new { id="link1" }) @Html.ActionLink("这是一个连接", "Index",null, new { id="link1" }) QueryString与Html属性同时存在 @Html.ActionLink("这是一个连接", "Index", "Home", new { page = 1 }, new { id = "link1" }) @Html.ActionLink("这是一个连接", "Index" , new { page = 1 }, new { id = "link1" })
复制代码

TextBox * — Renders a text box." style="margin: 0px; padding: 0px;">生成结果为:

复制代码
<a href="/">这是一个连接</a> 带有QueryString的写法 <a href="/?page=1">这是一个连接</a> <a href="/?page=1">这是一个连接</a> 有其它Html属性的写法 <a href="/?Length=4" id="link1">这是一个连接</a> <a href="/" id="link1">这是一个连接</a> QueryString与Html属性同时存在 <a href="/?page=1" id="link1">这是一个连接</a> <a href="/?page=1" id="link1">这是一个连接</a>
技术专家 | 园豆:230 (菜鸟二级) | 2018-03-14 14:27
0
 @Html.TextBox("textfield2","",

  new { @class = "input-text", id = "textfield", style="color:#999"   ,onfocus="if(value==defaultValue){value='';this.style.color='#000'}"

    ,onblur="if(!value){value=defaultValue; this.style.color='#999'}"

  ,size="60"})

 

 

你试试。

Shendu.CC | 园豆:2138 (老鸟四级) | 2018-03-14 15:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册