文本框自定义属性为空 [英] TextBox Custom Attribute is Empty

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

问题描述

我设置在这样的标记的自定义属性。

I am setting a custom attribute in the markup like this..

<asp:TextBox runat="server" guid="" ID="txtlocation1" type="text" class="autocomplete short-field require" name="location1" autocomplete="off" datasource="locations" />

的Javascript设置它的价值,我想读这样的按钮点击的价值...

Javascript sets the value of it and I am trying to read the value on button click like this...

var val = txtlocation1.Attributes["guid"];

我总是得到一个空字符串..任何想法?
PS:我不是在设置code中的属性,虽然

I always get an empty string.. any ideas? PS: I am not setting the attribute in code though.

推荐答案

自定义属性不会被发送回服务器...您可以使用一个HiddenFeild控制而不是保存数据,并用JavaScript和服务器上改变它,你将读取更新值

custom attributes will not be sent back to server...you may use a HiddenFeild control instead to hold your data and change it with javascript and on server you will read the updated value

这篇关于文本框自定义属性为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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