gpt4 book ai didi

c# - 为什么我的更新面板会生成数百个脚本 block ?

转载 作者:行者123 更新时间:2023-11-29 22:28:03 25 4
gpt4 key购买 nike

我有一个带有转发器的 asp.net web 表单。在这个转发器中有多个控件,我通过 ItemCreated 事件影响这些控件的 javascript 函数。我用这种代码做了这个:

btnBareme.OnClientClick = string.Format("ChangeBareme('{0}','{1}',this); return false", item.Num_dossier, item.IdDemande);

javascript 函数“changeBareme()”定义在页面的标题中。它工作正常,但我需要独立于页面的其他元素更新转发器。

所以我用 asp:UpdatePanel 包围了转发器。像这样:

<asp:UpdatePanel ID="UpdatePnl2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<h1>Foo</h1>
</div>

<div>
<asp:Repeater runat="server" ID="rptFoo" OnItemCreated="rptFoo_ItemCreated" OnItemCommand="rpt_ItemCommand">
<HeaderTemplate>
<table id="TabRep" class="DataRepeater">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
SomeContent Here with controls
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
<br/>
</div>
</ContentTemplate>
</asp:UpdatePanel>

那里.. 它不会工作。更新面板外的页面控件丢失了它们的状态,在 Debug模式下,生成了数百个“脚本 block ”..

Screenshot VS

我的问题是我不太了解更新面板是如何处理内部 javascript 的。所以我需要更有经验的人的一些建议。我怎样才能使这个更新面板有效?数百个脚本 block 是什么?我需要使中继器与页面的其余部分更加“独立”..

提前致谢。

最佳答案

这些脚本 block 在这里是因为每个按钮都有一个脚本 block

<input type="button" onclick="changebareme.."/>

这里不是更新面板的问题。

更好的方法是为每个按钮添加一个通用的 css 类。然后使用 javascript 选择所有按钮,并观察所有按钮的点击事件。

关于c# - 为什么我的更新面板会生成数百个脚本 block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8397076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com