如何访问隐藏的Asp:Textbox [英] How to Access a Asp:Textbox that is hidden

查看:75
本文介绍了如何访问隐藏的Asp:Textbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用ASP.NET(c#)和jscript.
我有一个隐藏的文本框

<

Hi,
I am using ASP.NET (c#) and using jscript.
I have a text box that is hidden

<

asp : 文本框 =" txtOtherTitle" runat asp : 文本框 >

<

asp:TextBox ID="txtOtherTitle" runat="server" Visible="false"></asp:TextBox>

I have a drop downlist

<

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";

}

}

问题是,当文本框可见时,它工作正常,但是当文本框隐藏时,它显示以下错误

Microsoft JScript运行时错误:'style'为null或不是对象
at

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

Microsoft JScript runtime error: 'style' is null or not an object
at

otherTitleText.style.visibility =

;

"visible";

 





推荐答案



有关的问题 asp.net,请发布 至: http://forums.asp. net/ .

,谢谢,
哈里

Hi,

For the
questions relating to asp.net ,please post to: http://forums.asp.net/.

Thanks,
Harry


这篇关于如何访问隐藏的Asp:Textbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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