1

我想使用带有图像的更新面板。当图像选择并显示以进行预览时,仅更新该部分。

<div class="field-block button-height">
  <label for="file" class="label">
    <b>Image</b> (*.jpg)
  </label>
  <table>
    <tr>
      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
          <td>
            <span class="input file">
              <span class="file-text"></span>
              <span class="button compact">Select file</span>
              <asp:FileUpload ID="fuMovieLogo" runat="server" CssClass="file withClearFunctions />"
            </span>
            <br />
            <small class="input-info">Max file size: 2MB</small>
            <asp:Button ID="btnPreview" runat="server" Text="Preview" onclick="btnPreview_Click" />
            <asp:Button ID="btnCancelprev" runat="server" Text="Cancel" onclick="btnCancelprev_Click"/>
          </td>
          <td style="padding-left:10px">
            <asp:Image ID="imgTheatreLogo" runat="server" Width="130px" />
            <br />
            <asp:Label ID="lblupdatelogo" runat="server" CssClass="lbl" Visible="false" Text="FDMovieUntitled.jpg"></asp:Label>
          </td>
        </ContentTemplate>
        <Triggers>
          <asp:AsyncPostBackTrigger ControlID="btnPreview" EventName="Click" />
          <asp:AsyncPostBackTrigger ControlID="btnCancelprev" EventName="Click" />
        </Triggers>
      </asp:UpdatePanel>
    </tr>
  </table>
</div>

请帮我。

4

1 回答 1

0

所以你只需要稍微重组你的标记。您需要放置imgTheatreLogo在更新面板内。触发器实际上由更新面板之外的控件处理。请参阅此文档以获取有关其UpdatePanel工作原理的参考。

<?xml version="1.0" encoding="utf-8"?>
<div class="field-block button-height">
  <label for="file" class="label">
    <b>Image</b> (*.jpg)
  </label>
  <table>
    <tr>
      <td>
        <span class="input file">
          <span class="file-text"></span>
          <span class="button compact">Select file</span>
          <asp:FileUpload ID="fuMovieLogo" runat="server" CssClass="file withClearFunctions />"
        </span>
        <br />
        <small class="input-info">Max file size: 2MB</small>
        <asp:Button ID="btnPreview" runat="server" Text="Preview" onclick="btnPreview_Click" />
        <asp:Button ID="btnCancelprev" runat="server" Text="Cancel" onclick="btnCancelprev_Click"/>
      </td>
      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
          <td style="padding-left:10px">
            <asp:Image ID="imgTheatreLogo" runat="server" Width="130px" />
            <br />
            <asp:Label ID="lblupdatelogo" runat="server" CssClass="lbl" Visible="false" Text="FDMovieUntitled.jpg"></asp:Label>
          </td>
        </ContentTemplate>
        <Triggers>
          <asp:AsyncPostBackTrigger ControlID="btnPreview" EventName="Click" />
          <asp:AsyncPostBackTrigger ControlID="btnCancelprev" EventName="Click" />
        </Triggers>
      </asp:UpdatePanel>
    </tr>
  </table>
</div>
于 2013-08-09T12:13:08.667 回答