UpdatePanel and modifying controls outside of the

2019-09-01 06:31发布

I have a control inside of an UpdatePanel. The UpdatePanel has an AsyncPostBack trigger associated with the inner control. This works just fine.

I have another control containing a SSRS ReportViewControl that I would like to conditionaly hide based on the results from the postback event of the UpdatePanel mentioned above.

The ReportViewerControl is not inside of an UpdatePanel and I would like to keep it this way. How can I hide the ReportViewerControl based on the postback event of an UpdatePanel inside of another control?

I am assuming that many problems would spring up if I place the ReportViewerControl inside of an UpdatePanel, anyone know for sure?

4条回答
时光不老,我们不散
2楼-- · 2019-09-01 06:33

You could create a script inside you update panel content template and hide your control form javascript.

  <script type="text/javascript">
     Sys.Application.Add_load(MyFunctionThatHides);
   </script
查看更多
劫难
3楼-- · 2019-09-01 06:47
  1. Hide the content through server side code but rather to use javascript (possibly injected by the server through a postback) as suggested by Machinegon.
  2. Have a second UpdatePanel around the other content that you want to hide. (You can't make the current one bigger, but making a second shouldn't cause problems.) Have that second update panel set the same button as the trigger. (You can have a trigger that's outside of the update panel, you just can't update content outside of the update panel.) If the update is conditional (you only sometimes change the content when the button is clicked) then you can set the only trigger for the second panel to be a hidden button which you Click in code from the handler of the first button click.
查看更多
Juvenile、少年°
4楼-- · 2019-09-01 06:52

You can use following code after processing the Async AJAX call on server and just before returning the response to client/browser

this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowHideReportViewerJSScript", <JS code to show/hide reportviewer>, true);

I assume you have scriptmanager placed on the ASPX page

查看更多
Animai°情兽
5楼-- · 2019-09-01 06:57

The ReportViewerControl is not inside of an UpdatePanel and I would like to keep it this way.

I did a simple trick. I created a another Updatepanel and put a literal control side the update panel and this update panel code Is Above the "Control you want to hide"

something like this

 <asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Always" >
    <ContentTemplate>
          <asp:Literal runat="server" ID="literal1"></asp:Literal>
     </ContentTemplate>
  </asp:UpdatePanel>

Then in Code behind I inject CSS

something like this

literalDvControl.Text = "<style> #YourControlID{ display:none;}</style>";

This seems to be working. Basically literal control is injecting style tag and browser is very quick to react.

but do read about this . Using <style> tags in the <body> with other HTML

查看更多
登录 后发表回答