【发布时间】:2011-02-23 14:19:56
【问题描述】:
我想根据下拉列表中选择的值更改文本框的可见性。
我已经创建了这样的函数:
function ShowGiftCardSource() {
var ddlGiftCardSource = document.getElementById('<%=ddlGiftCardSource.ClientID%>');
var txtGiftCardSource = document.getElementById('<%=txtGiftCardSource.ClientID%>');
if (ddlGiftCardSource.value == "Other") {
txtGiftCardSource.style.visibility = "visible";
txtGiftCardSource.focus();
}
}
在 CS 页面中:
ddlGiftCardSource.Attributes.Add("onChange", "OnSelectedIndexChanged();");
在控件中:
<asp:DropDownList ID="ddlGiftCardSource" runat="server" Width="151px" onChange="ShowGiftCardSource();">
但我收到以下错误:
Microsoft JScript runtime error: Object expected
有人可以帮我解决吗?
【问题讨论】:
标签: c# javascript drop-down-menu onchange