2012-03-28 96 views
0

ASP.net(C#),VS2010 7从另一个调用clientsideevent

新建Webdev的一个clientsideevent,运,所以这可能是一个简单的语法的事情,但在这里不言而喻...

长的故事总之,我不得不在GridView上强制回发一个显示使用ASPxUploadControl上载的附件的GridView。我把GridView放在一个ASPxCallbackPanel中,并且在使用ASPxCallbackPanel.PerformCallback()上传附件后,试图让我的GridView在页面上更新。

这里是Upload控件,在它的'ClientSideEvent是我试图从下面显示的Button调用clientSideEvent的地方。只是试图强制按钮点击,但我试图从代码隐藏,但没有奏效。任何帮助,将不胜感激!

<dxuc:ASPxUploadControl ID="FileUpload1" runat="server" 
     ClientInstanceName="uploader" 
     ShowAddRemoveButtons="False" 
     ShowUploadButton="True" 
     AddUploadButtonsHorizontalPosition="Center" 
     AddUploadButtonsVerticalPosition="Top" FileInputCount="1" 
     UploadMode="Advanced" 
     OnFileUploadComplete="UploadControl_FileUploadComplete" 

     Size="30"> 
     <ClientSideEvents FileUploadComplete="function(s, e) { Button1.Click; }" /> 
     <%-- <AdvancedModeSettings EnableMultiSelect="True" /> "does not have public property named "advancedModeSettings" version is too old--%> 
     <ValidationSettings 
      AllowedFileExtensions=".doc,.pdf,.xls,.txt,.jpeg,.jpg,.gif,.png,.oft,.htm,.html,.mht,.rtf,.zip" 
      MaxFileSize="5242880" 
      FileDoesNotExistErrorText="This file can't be found." 
      GeneralErrorText="Custom file uploading fails due to an external error that doesn't relate to the ASPxUploadControl's functionality" 
      MaxFileSizeErrorText="Size of the uploaded file exceeds maximum file size"> 
      <ErrorStyle ForeColor="Red"/> 

     </ValidationSettings> 
    </dxuc:ASPxUploadControl> 

这里是GridView以及我成功刷新网格的按钮。

<div> 
     <dxe:ASPxButton ID="ASPxButton1" runat="server" ClientInstanceName="Button1" Text="Reload Panel" AutoPostBack="False"> 
      <ClientSideEvents Click="function(s, e) {ASPxCallbackPanel1.PerformCallback(); e.processOnServer = true;}" /> 
     </dxe:ASPxButton> 
     <dx:ASPxCallbackPanel ID="ASPxCallbackPanel1" runat="server" 
      ClientInstanceName="ASPxCallbackPanel1" Width="492px" 
      Height="100%"> 
      <PanelCollection> 
      <dx:PanelContent runat="server"> 

       <asp:GridView ID="gvAttachment" SkinID="grid" runat="server" Width="98%" 

       OnRowDataBound="AttachmentControl_OnRowDataBound" 

       meta:resourcekey="gvAttachResource1" 
       PagerSettings-FirstPageText="<%$ Resources:CommonControlText,FirstPageText %>" 
       PagerSettings-LastPageText="<%$ Resources:CommonControlText,LastPageText %>" 
       PagerSettings-PreviousPageText="<%$ Resources:CommonControlText,PreviousPageText %>" 
       PagerSettings-NextPageText="<%$ Resources:CommonControlText,NextPageText %>" 
        AutoGenerateColumns="False"> 
       <EmptyDataRowStyle CssClass="emptyData" /> 
       <EmptyDataTemplate> 
        <table class="usercontroldetail container_table"> 
         <tr> 
          <td class="tdlayout"> 
           <asp:Label ID="Localize1" runat="server"> 
            <%= Placeholder %> 
           </asp:Label> 
          </td> 
         </tr> 
        </table> 
       </EmptyDataTemplate> 
       <Columns> 
        <asp:BoundField DataField="AtchmtId" HeaderText="Attachment ID" 
         visible = "false" meta:resourcekey="BoundFieldResource1"> 
         <ItemStyle HorizontalAlign="Center" /> 
        </asp:BoundField> 
        <asp:BoundField DataField ="FileNm" HeaderText="File Name" /> 
        <asp:BoundField DataField="UsrNm" HeaderText="Uploaded By" 
         /> 
        <asp:BoundField DataField="AtchmtDt" HeaderText="Date" 
         /> 
        <asp:BoundField DataField="FileSizeCnt" HeaderText="File Size" 
         /> 
        <asp:TemplateField AccessibleHeaderText="Actions" HeaderText="Actions"> 
         <ItemTemplate> 
          <div style="text-align:center;"> 
           <asp:LinkButton ID="btnDelete" Visible="False" runat="server" 
            ToolTip="Delete Selected Attachment" 
            OnClick="btnDelete_Click" 
            Text="Delete" CausesValidation="True" DisableOnSubmit="True" Group="" 
            meta:resourcekey="btnDeleteResource1" /> 
           <asp:Label ID="lblPipe" runat="server" Text="|" /> 
           <asp:LinkButton ID="btnView" Visible="False" runat="server" 
            ToolTip="View Selected Attachment" 
            OnClick="btnView_Click" 
            Text="View" CausesValidation="True" DisableOnSubmit="True" Group="" 
            meta:resourcekey="btnViewResource1" /> 
          </div> 
         </ItemTemplate> 
         <ItemStyle Wrap="false" /> 
        </asp:TemplateField> 
       </Columns> 

     <%--<PagerSettings FirstPageText="First" LastPageText="Last" NextPageText="Next &gt;" PreviousPageText="&lt; Previous"></PagerSettings>--%> 

       <RowStyle CssClass="row_odd" /> 
       <AlternatingRowStyle CssClass="row_even" /> 
      </asp:GridView> 
      </dx:PanelContent> 
      </PanelCollection> 
      </dx:ASPxCallbackPanel> 

仅供参考:GridView正在获取新的附件。我只是没有看到它在页面上,因为UploadControl只更新自身。

编辑:如下图所示使用OnClick()方法。 DERP。忘记了ASPx按钮继承了所有的ASP按钮方法。但是现在,我原来制作按钮隐形的计划似乎被挫败了。当Button1.OnClick()被调用时Button的Visible属性设置为“false”。它说Button1没有被定义。无论如何围绕这个?

<ClientSideEvents FileUploadComplete="function(s, e) { Button1.OnClick(); }" /> 

回答

0

如果我有你的权利,你可以通过属性称为a updateMode操作页面上的所有更新面板的行为(有条件,总是)。如果所有模式均设置为始终,更改一个更新面板将导致全部刷新。