如何在文本框中间使用Ia标签名称。 [英] How Do I Take Ia Label Name In Middle Of Textbox.

查看:76
本文介绍了如何在文本框中间使用Ia标签名称。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨fr !!!!

如何在文本框中间取一个标签。例如,在Facebook注册时,我们输入我们的名字电子邮件和密码。



更新



当我们开帐户时他们想要我们输入我们的名字,姓氏电子邮件密码等信息当我们点击姓氏,名字文本框和文字框中写的姓氏消失时我们写了我们在文本框中的名称。

hi frnds!!!!
how do taking a label in the middle of text box. For example in Facebook when we sign up and we enter our name email and password.

UPDATE

When we make account In Facebook they want information we enter our first name, last name email password etc. when we click on last name, first name text box and last name written in text box disappear and we write our name in text box.

推荐答案

在ASP.NET MVC中,执行此操作的代码是在razor视图中使用java-script,如下一个示例所示:



In ASP.NET MVC the code for doing this is by using java-script in razor view like in the next example:

@Html.TextBox("searchValue", Session["SearchValue"] == null || ((string)Session["SearchValue"]).Length == 0 ? Resources.Resource.SearchLabel : (string)Session["SearchValue"], new { @class = "quickSearchTextBox", onFocus = "if (this.value=='" + Resources.Resource.SearchLabel + "') this.value='';"})







想法是测试如果用户在文本框中输入内容(或全部删除),则输入没有输入显示消息提示的情况,否则保持用户输入。在上面的代码中,我在会话中保留用户输入的值,以便在回发之间不丢失。




The idea is to test if the user input something (or delete all) in the text box, and in the case there is no input to show a message hint, otherwise to keep the user input. In the code above I keep in the Session the value input by user to not lost it between post backs.


这称为占位符

我正在用一个ASP .NET示例向你解释这个。

That is called, placeholder.
I'm taking a ASP .NET example to explain you this.
<asp:textbox id="fnameTxt" runat="server" placeholder="First Name" />



或者可以在 W3c [ ^ ]。



祝你好运:)

-KR


Or may find bit more appropriate answer on W3c[^].

Good Luck :)
-KR

这篇关于如何在文本框中间使用Ia标签名称。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆