日期:2014-05-16  浏览次数:20291 次

在WEB用户控件 读取TextBox的值?
好象很简单的问题,请教一下

------解决方案--------------------
TextBox是textarea?
这样document.getElementById( "textareaID ").value
------解决方案--------------------
楼上写的那个document.getElementById( "控件ID ").value的方法很无敌,几乎所有控件都好用
------解决方案--------------------
document.getElementById( " <%TextBox控件ID.ClinetID%> ").value
------解决方案--------------------
LZ 要干嘛呀?!被你弄糊涂了

.ascx.cs 里直接就能获取到的呀,比如

.ascx 里有
<asp:TextBox id= "username " runat= "server " Width= "198px "> </asp:TextBox>

.ascx.cs 可以直接获得
string un = this.username.text;


------解决方案--------------------
楼主是不是指以下情况:某个页面,如:MyPage.aspx里使用了一个自定义的控件 <uc1:WebUserControl ID= "WebUserControl1 " runat= "server " /> ,如:WebUserControl.ascx,在该自定义控件里有一个TextBox,如: <asp:TextBox ID= "tb1 " runat= "server "> </asp:TextBox> ,那可以在MyPage.aspx里使用下面的方法取值:
function d1()
{
var v = document.getElementById( "WebUserControl1$tb1 ").value;
alert(v);
}