从txtbox.text获取文本的问题 [英] problem to get the text from txtbox.text

查看:118
本文介绍了从txtbox.text获取文本的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,请帮助我解决这个非常奇怪的问题!
我有一个用户控件.它由2个文本框和一些引发onclientclick 事件的标签和linkButton 组成.
我希望文本框执行一些javascript验证.所以我想使用javascript
进入text-box元素
document.getElementById(''<%= txtID.ClientID %>'')-这样可以正确获取元素.奇怪的是-该值始终为空字符串!即使存在文本,也可能是因为用户控件位于用户控件内部,而该用户控件位于带有主页面的页面的侧面更新面板中带有页面控制的listview (ItemTemplate)侧面...有人遇到过吗?有任何想法吗?

hello, please help me in this very wierd problem I''m having!
I have a user control. it''s composed out of 2 textbox and some labels and linkButton that fire onclientclick event.
I want the textbox to do some javascript validations. so I''m trying to get to the text-box element using javascript

document.getElementById(''<%= txtID.ClientID %>'') - this gets the element properly. The strange thing is - the value is always empty string! even when there IS text it might be because the usercontrol is inside an usercontrol that in side listview (ItemTemplate) with pager control in side update panel in side a page with master page ... anyone ever encountered this? any ideas?

thanks in advanced!

推荐答案

我猜这意味着您遇到了操作顺序问题.尝试从后面的代码中释放JavaScript.
I am guessing this means you have an order of operations problem. Try instead emitting your javascript from your code behind.


如果在客户端传递html,它将独立于所有这些MasterPage,UserControl或Pager.在客户端,一切都一样.

检查控件.如果在客户端呈现了< input type ="text",则它必须正确找到document.getElementById("...") .value.

如果您选择的是正确的,请让我知道.只需放置一个断点,或添加调试器即可;在javascript行之前,并检查此控件的externalHtml以查看该控件的确切含义.

如果它是普通的输入控件,则肯定有一个Value属性.

;)
If you pass an html in the client, it will be independent of all these MasterPages, UserControl or Pager. In the client side everything is the same.

Inspect the control. If you have an <input type="text" rendered in the client side, it must find the document.getElementById("...").value properly.

Please let me know if you are looking on the right one. Just put a breakpoint, or add debugger; before the javascript line and check the outerHtml of this control to see what exactly the control is.

If it is a normal input control, there bound to be a Value property.

;)


我的问题不就是清除

我在列表视图(在item-template中)中有一个usercontrol,其中包含一个按钮和一个文本框.由于某些原因,我无法达到文本框的值(位于列表视图内的用户控件内)

为什么呢?

谢谢!
my by my question dont was Clear

I got a usercontrol inside a listview (in the item-template ) which contains a button and a textbox inside. for some reason I can''t reach the value of the textbox (which is inside the user control inside the listview)

why is that?

thanks!


这篇关于从txtbox.text获取文本的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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