weixin_33725270 2014-05-28 09:13 采纳率: 0%
浏览 35

Ajax UpdatePanel无法正常工作?

I am very new to Ajax and have been impressed with reading about it and how you can refresh a area of a page and not the whole thing. I thought doing this when reading about it was fairly easy but I'm abit stuck on an area.

I have a Report-viewer on my page which uses a ScriptManager and I have a calendar control which when I click a day will need to refresh to put that into a Textbox.

The Report-viewer is on the page when it loads it needs to be passed a parameter but can only get that after they have selected something from a combobox

So this is what I have done so far:

<li>
    <asp:UpdatePanel runat="server" ID="updateDOI">
        <ContentTemplate>

             <input id="txt_DateOfInterview" type="Date" class="aclass" runat="server" />

                  <asp:ImageButton runat="server" ImageUrl="~/Images/Calender.png" ID="calendericonDOI" CssClass="calendericonDOI ClanderDOI" OnClick="calendericonDOI_Click"></asp:ImageButton>

                  <asp:Calendar runat="server" ID="ClanderDOI" CssClass="ClanderDOI" OnSelectionChanged="ClanderDOI_SelectionChanged" BorderColor="#6a3d98" OnVisibleMonthChanged="ClanderDOI_VisibleMonthChanged">
                       <TitleStyle BackColor="Orange" />
                  </asp:Calendar>

        </ContentTemplate>
     </asp:UpdatePanel>

As you can see i have a wrapped a UpdatePanel around the calender and also the input box that will get populated with the day selected

And then with the report viewer I have done the same:

<asp:UpdatePanel runat="server" ID="UpdatePanel1">
      <ContentTemplate>
           <rsweb:ReportViewer ID="rvSickness" runat="server" BackColor="#6e4594" Font-Names="Arial" Font-Size="8pt" Height="100%" ProcessingMode="Remote" WaitMessageFont-Names="Arial" WaitMessageFont-Size="14pt" Width="450px" ShowCredentialPrompts="False" ShowParameterPrompts="False" ShowPromptAreaButton="True" ShowToolBar="true" ShowFindControls="False" ToolBarItemBorderColor="#FF9900" ToolBarItemHoverBackColor="#FF9900" ForeColor="White">
                   <ServerReport ReportServerUrl="" />
                                </rsweb:ReportViewer>
      </ContentTemplate>
 </asp:UpdatePanel>

But what I don't understand it that the ReportViewer is still refreshing when I do anything.

My question is why is the Report-viewer refreshing when I am selecting something from a calender control? Is it because it has not been passed a parameter yet or have I done something wrong?

  • 写回答

1条回答 默认 最新

  • weixin_33675507 2014-05-28 10:10
    关注

    what you can do is take two update panels

    In first UpdatePanel in which i took a DropDownList(here i took some sample dropdown list items)

    <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:DropDownList ID="DropDownList1" ClientIDMode="AutoID" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                    <asp:ListItem>one</asp:ListItem>
                    <asp:ListItem>two</asp:ListItem>
                    <asp:ListItem>three</asp:ListItem>
                    <asp:ListItem>four</asp:ListItem>
                </asp:DropDownList>
            </ContentTemplate>
        </asp:UpdatePanel>
    

    Second update panel in which i took your ReportViewer

    <asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional">
        <ContentTemplate>
            <rsweb:ReportViewer ID="rvSickness" runat="server" BackColor="#6e4594" Font-Names="Arial" Font-Size="8pt" Height="100%" ProcessingMode="Remote" WaitMessageFont-Names="Arial" WaitMessageFont-Size="14pt" Width="450px" ShowCredentialPrompts="False" ShowParameterPrompts="False" ShowPromptAreaButton="True" ShowToolBar="true" ShowFindControls="False" ToolBarItemBorderColor="#FF9900" ToolBarItemHoverBackColor="#FF9900" ForeColor="White">
             <ServerReport ReportServerUrl="" />
            </rsweb:ReportViewer>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>
    

    Now in code behind you can pass the id to your ReportViewer on DropDownList1_SelectedIndexChanged event like this

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
            {
                //your code here
            }
    

    Note: I didn't took you calendar and other controls in this answer as you wanted to update the ReportViewer only when you select an item from DropDownList

    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配