C# UpdatePanel和修改面板外部的控件

C# UpdatePanel和修改面板外部的控件,c#,asp.net,ajax,reporting-services,ajaxcontroltoolkit,C#,Asp.net,Ajax,Reporting Services,Ajaxcontroltoolkit,我在UpdatePanel中有一个控件。UpdatePanel具有与内部控件关联的AsyncPostBack触发器。这个很好用 我还有另一个控件,其中包含一个SSRSReportViewControl,我想根据上面提到的UpdatePanel的回发事件的结果有条件地隐藏该控件 ReportViewerControl不在UpdatePanel内,我想这样保存它。如何根据UpdatePanel的回发事件在另一个控件中隐藏ReportViewerControl 我假设如果我将ReportViewerC

我在
UpdatePanel
中有一个控件。
UpdatePanel
具有与内部控件关联的
AsyncPostBack
触发器。这个很好用

我还有另一个控件,其中包含一个SSRS
ReportViewControl
,我想根据上面提到的
UpdatePanel
的回发事件的结果有条件地隐藏该控件

ReportViewerControl
不在
UpdatePanel
内,我想这样保存它。如何根据
UpdatePanel
的回发事件在另一个控件中隐藏
ReportViewerControl


我假设如果我将
ReportViewerControl
放在
UpdatePanel
中,会出现很多问题,有人知道吗?

您可以在更新面板内容模板中创建一个脚本并隐藏控件表单javascript

  <script type="text/javascript">
     Sys.Application.Add_load(MyFunctionThatHides);
   </script

Sys.Application.Add_load(myfunctionthatthiels);

您可以在服务器上处理异步AJAX调用之后,在将响应返回到客户机/浏览器之前,使用以下代码

this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowHideReportViewerJSScript", <JS code to show/hide reportviewer>, true);
this.Page.ClientScript.RegisterStartupScript(this.GetType(),“ShowHiderReportViewerJSScript”,true);
我想您已经在ASPX页面上放置了scriptmanager

  • 通过服务器端代码隐藏内容,而是按照Machinegon的建议使用javascript(可能由服务器通过回发注入)
  • 在要隐藏的其他内容周围放置第二个
    UpdatePanel
    。(你不能使当前的一个更大,但制造第二个应该不会引起问题。)让第二个更新面板设置与触发器相同的按钮。(您可以有一个位于更新面板之外的触发器,但不能更新更新面板之外的内容。)如果更新是有条件的(您有时只在单击按钮时更改内容)然后,您可以将第二个面板的唯一触发器设置为隐藏按钮,您可以从第一个按钮单击的处理程序在代码中单击该按钮
  • ReportViewerControl不在UpdatePanel中,我希望 我喜欢这样

    我做了一个简单的把戏。我创建了另一个Updatepanel,并在更新面板旁边放置了一个文本控件,这个更新面板代码位于“要隐藏的控件”上方

    像这样的

     <asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Always" >
        <ContentTemplate>
              <asp:Literal runat="server" ID="literal1"></asp:Literal>
         </ContentTemplate>
      </asp:UpdatePanel>
    
    literalDvControl.Text = "<style> #YourControlID{ display:none;}</style>";
    

    谢谢您的回复。这种情况打破了我的模式,因为在调用ReportViewer控件的回发时,我不假设该控件存在。是否可以执行类似的操作,但不查找控件,而是查找另一个JS方法,该方法可能已从另一个控件注册,也可能尚未从另一个控件注册。如果这是可能的,那么我可以在加载带有ReportViewer的控件时注册另一个JS函数?