【问题标题】:Getting asp:panel elements获取 asp:panel 元素
【发布时间】:2014-04-07 07:12:18
【问题描述】:

我在名为“sample.ascx”的 ascx 中有一个名为“sp”的面板。

<asp:Panel ID="sp"  runat="server" >
</asp:Panel>

我的“sample.ascx.cs”文件动态地将“Label”和“Textbox”等组件添加到此面板。我想获取“sample.ascx”的javascript中所有组件的值。 请帮忙!

【问题讨论】:

  • 你可以试试var sp = document.getElementById('&lt;%: sp.ClientID %&gt;');,然后用children

标签: c# javascript asp.net .net


【解决方案1】:

为服务器控件设置 ClientIDMode="Static",您需要使用 JS 中的 id 本身轻松访问。 然后尝试 var res= $('#sp'); var val1=res.find('#textbox1').val();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 2016-05-29
    • 1970-01-01
    相关资源
    最近更新 更多