如何访问在ASP.Net自定义文本框的属性? [英] How can I access custom Textbox attributes in ASP.Net?

查看:156
本文介绍了如何访问在ASP.Net自定义文本框的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用/滥用CSS类和自定义HTML属性来提供默认的数据为一组文本框。在code-面前这个看起来像以下(有一些JavaScript支持,以处理检查/设置默认数据时,该字段为空):

I am using/abusing CSS classes and custom html attributes to provide default data to a set of textboxes. The code-front for this looks like the following (with some supporting javascript to handle checking/setting the default data when the field is blank):

< ASP:文本框ID =TXT_LenderName类='defaultText数据默认='机构名称'=服务器>< / ASP:文本框>

这工作。

我的工作的code-背后来处理这种形式。我希望能够在 TXT_LenderName.Text 的值进行比较的数据默认属性的值,但我一直没能找到一种方式来获得的自定义HTML属性的值。建议?

I am working on the code-behind to process this form. I would like to be able to compare the value of the TXT_LenderName.Text to the value of the data-default attribute, but I haven't been able to find a way to get the value of a custom html attribute. Suggestions?

推荐答案

这是测试和工作

string customAttrDataDefault = TXT_LenderName.Attributes["data-default"];
txtpassword.Attributes.Add("value","Password value");

这篇关于如何访问在ASP.Net自定义文本框的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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