使用 jquery 更改按钮的可见性 - UpdatePanel
我有 2 个按钮(过滤器和查看摘要)和一个更新面板。更新面板包含网格。单击过滤器按钮时 - 将从数据库中获取数据并触发更新面板。现在,根据数据的内容,我想更改视图摘要按钮的可见性。
我已经尝试过 - hfSummaryVis 是我在更新面板中设置的隐藏字段
function pageLoad() {
alert('<%=hfSummaryVis.Value %>');
}
警报消息始终为空。我也尝试过 document.ready。 Document.Ready 仅在页面首次加载时调用。
请帮忙
谢谢,
<div id="divOrderDateSelector" class="FloatLeft PadDiv" style="padding-top: 3px;">
<asp:Button ID="btnFilter" runat="server" Text="Filter"
OnClick="btnFilter_Click" CssClass="DefaultButton"/>
<asp:Button ID="btnSummary" runat="server" Text="View Summary"
OnClick="btnSummary_Click" CssClass="DefaultButton"
onclientclick="return false"/>
</div>
<br/>
<div id="divbuy" class="ClearBoth PadBottom">
<span class="SectionHeader Block" >Buys</span>
<asp:UpdatePanel ID="upStatus" runat="server" UpdateMode="Conditional" >
<Triggers >
<asp:AsyncPostBackTrigger ControlID="btnFilter" EventName="Click"/>
</Triggers>
<ContentTemplate >
<asp:HiddenField ID="hfSummaryVis" runat="server" />
<asp:GridView ID="gvSummary" runat="server" AutoGenerateColumns="False"
CssClass="ContrastTable WideTable" GridLines="None"
onrowdatabound="gvSummary_RowDataBound">
<EmptyDataTemplate>No Records Found</EmptyDataTemplate>
<RowStyle CssClass="MainTableRow" />
<AlternatingRowStyle CssClass="AlternateRow" />
<HeaderStyle CssClass="HeaderRow" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lkBtnOpen" runat="server" CssClass="Expand ButtonCell PlainLink"
ToolTip="Click to see details of the date's orders."
Text=" " OnClientClick="showCusipAccountDetails(" />
<asp:LinkButton ID="lkBtnClose" runat="server" CssClass="Collapse ButtonCell PlainLink Hidden"
ToolTip="Click to close."
Text=" " />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Strategy Series">
<ItemTemplate>
<asp:Label ID="lblStrategySeries" runat="server" />
</ItemTemplate>
...
I have 2 buttons (Filter and view summary) and a updatepanel. The update panel hold the grid. When the filter button is clicked - the data is fetched from the database and the updatepanel is triggered. Now based on the contents of the data, i want to change the visibility of the view summary button.
I have tried - hfSummaryVis is the hiddenfield that i set in the update panel
function pageLoad() {
alert('<%=hfSummaryVis.Value %>');
}
The alert message is always blank . I have also tried document.ready. Document.Ready is only called when the page loads for the first time.
Please help
Thanks,
<div id="divOrderDateSelector" class="FloatLeft PadDiv" style="padding-top: 3px;">
<asp:Button ID="btnFilter" runat="server" Text="Filter"
OnClick="btnFilter_Click" CssClass="DefaultButton"/>
<asp:Button ID="btnSummary" runat="server" Text="View Summary"
OnClick="btnSummary_Click" CssClass="DefaultButton"
onclientclick="return false"/>
</div>
<br/>
<div id="divbuy" class="ClearBoth PadBottom">
<span class="SectionHeader Block" >Buys</span>
<asp:UpdatePanel ID="upStatus" runat="server" UpdateMode="Conditional" >
<Triggers >
<asp:AsyncPostBackTrigger ControlID="btnFilter" EventName="Click"/>
</Triggers>
<ContentTemplate >
<asp:HiddenField ID="hfSummaryVis" runat="server" />
<asp:GridView ID="gvSummary" runat="server" AutoGenerateColumns="False"
CssClass="ContrastTable WideTable" GridLines="None"
onrowdatabound="gvSummary_RowDataBound">
<EmptyDataTemplate>No Records Found</EmptyDataTemplate>
<RowStyle CssClass="MainTableRow" />
<AlternatingRowStyle CssClass="AlternateRow" />
<HeaderStyle CssClass="HeaderRow" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lkBtnOpen" runat="server" CssClass="Expand ButtonCell PlainLink"
ToolTip="Click to see details of the date's orders."
Text=" " OnClientClick="showCusipAccountDetails(" />
<asp:LinkButton ID="lkBtnClose" runat="server" CssClass="Collapse ButtonCell PlainLink Hidden"
ToolTip="Click to close."
Text=" " />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Strategy Series">
<ItemTemplate>
<asp:Label ID="lblStrategySeries" runat="server" />
</ItemTemplate>
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在页面上有一个脚本管理器,然后挂钩
//Do Something Here
的事件。将其放入页面加载事件中:
You need to have a script manager on the page and then hook into the events of
//Do Something Here
.Put this in the page load event:
该隐藏文件是一个服务器控件,因此您必须获取该控件的 ClientID。试试这个
希望这有帮助。
That Hidden filed is a server control so you have to get the ClientID of that control. Try this
Hope this helps.
我使用更新面板解决了这个问题。
I solved that using an update panel.