如何使用已经有价值的asp文本框的占位符? [英] How to use place holder for asp text box which already having value?

查看:90
本文介绍了如何使用已经有价值的asp文本框的占位符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个asp文本框,它在pageload上有一个默认值,比如'a'。我需要显示文本框其余部分的占位符。我用过占位符属性。但是当它有文本时它没有显示占位符值。

解决方案

你可以使用属性集合,所以你会有类似的东西..



 Textbox1.Attributes.Add( 占位符 搜索 + a); 



a =在页面加载时通过文本框传递您的值

搜索=您的默认占位符名称(其余部分)你在问题中描述的文本框的一部分)







 Textbox1.Attributes [ 占位符] =  如果您正在使用,请搜索 + a; 

//或属性(占位符) vb.net


试试这个..

< asp:textbox id = Txt_example runat = server 占位符 = 示例 > < / asp:textbox >





支持IE8和9:



参考:如何支持占位符a在IE8和9中分配


Hi,
I have an asp textbox which is having a default value on pageload like 'a'. I need to show the place holder for the rest portion of the textbox. I have used place holder property. But it doesn't show place holder value when there is a text in it.

解决方案

you could use the attributes collection, So you would have something like..

Textbox1.Attributes.Add("placeholder", "Search" + a);


a=Pass your value whatever you want to pass in textbox on page load
Search=your default placeholder's name(For the rest of portion of textbox as you describe in Question)

or

Textbox1.Attributes["placeholder"] = "Search" + a;

// or Attributes("placeholder") if you're using vb.net


Try this..

<asp:textbox id="Txt_example" runat="server" placeholder="Example" ></asp:textbox>



Support IE8 and 9 :

Ref : How to support placeholder attribute in IE8 and 9


这篇关于如何使用已经有价值的asp文本框的占位符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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