如何访问隐藏的Asp:Textbox [英] How to Access a Asp:Textbox that is hidden
问题描述
< Hi, < asp : 文本框 =" txtOtherTitle" runat asp : 文本框 > < asp:TextBox ID="txtOtherTitle" runat="server" Visible="false"></asp:TextBox> < asp : DropDownList
< asp:DropDownList ID="dropdownlistTitle" runat="server">
< asp : ListItem asp : ListItem > ; asp:ListItem Text="Select Title" Value="Title"></asp:ListItem> < asp : ListItem asp : ListItem >
< asp:ListItem Text="Mr" Value="Mr"></asp:ListItem>
< asp : ListItem asp : ListItem >
< asp:ListItem Text="Mrs" Value="Mrs"></asp:ListItem>
< asp : ListItem asp : ListItem >
< asp:ListItem Text="Miss" Value="Miss"></asp:ListItem>
< asp : ListItem asp : ListItem >
< asp:ListItem Text="Dr" Value="Dr"></asp:ListItem>
< asp : ListItem asp : ListItem > <字体大小= 2 color =#0000ff"> <字体大小= 2 color =#0000ff">
</ asp:ListItem Text="Other" Value="Other"></asp:ListItem>
</ asp : DropDownList >
asp:DropDownList>
我尝试使用jscript函数使文本框可见 I try to makethe textbox visible using a jscript function 功能 titleChanged()
{ function titleChanged()
{ var 下拉列表= document.getElementById( var dropdown = document.getElementById("<%=dropdownlistTitle.ClientID%>");
var otherTitleText = document.getElementsByName( var otherTitleText = document.getElementsByName("
<%=txtOtherTitle.ClientID%> " );
);
var val = dropdown.options [dropdown.selectedIndex] .value;
var val = dropdown.options[dropdown.selectedIndex].value;
如果 (val == if (val == "Other") {
otherTitleText.style.visibility = 可见" ;
} "visible";
} 其他
{ else
{ otherTitleText.style.visibility = otherTitleText.style.visibility = 隐藏" ;
} "hidden";
} } 问题是,当文本框可见时,它工作正常,但是当文本框隐藏时,它显示以下错误 otherTitleText.style.visibility = The problem is when the textbox is visible it works fine but when the textbox is hidden it shows the below error otherTitleText.style.visibility = ;
"visible";
Hi, 这篇关于如何访问隐藏的Asp:Textbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
我正在使用ASP.NET(c#)和jscript.
我有一个隐藏的文本框
I am using ASP.NET (c#) and using jscript.
I have a text box that is hidden
I have a drop downlist
Microsoft JScript运行时错误:'style'为null或不是对象
at
Microsoft JScript runtime error: 'style' is null or not an object
at
推荐答案
与有关的问题 asp.net,请发布 至: http://forums.asp. net/ .
,谢谢,
哈里
For the questions relating to asp.net ,please post to: http://forums.asp.net/.
Thanks,
Harry