Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

How can I do partial update in this code

$
0
0
<div>

The basic program is uploading image files to a ftp server using AsyncFileUpload and then I want to do a partial update of all the image files that
have been uploaded to the ftp server.

In the old solution I used FileUpload so here we had a postback which caused the whole page to rendered back to client.
Now I want to do a partial update and only for all the images files that have been uploaded to the ftp server.
The control that is reponsible for this is called Repeater2 and is located in user control ArendeDetails.ascx

Now I paste in some relevant code for my problem.

I start with markup for page CrimeInvestigator.aspx that is using the user control ArendeDetails.ascx
********************************************************************************

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage3.master" AutoEventWireup="true" CodeFile="CrimeInvestigator.aspx.cs" Inherits="investigator_CrimeInvestigator" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register src="~/userControl/ArendeDetails.ascx" tagname="arendeDetalj" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>

    <uc1:arendeDetalj ID="arendeDetaljUsrCtrl" runat="server" />   

    <div id="bottomColumn">
       <p class="label">Upload images:</p>
       <%-- <asp:FileUpload ID="FileUploadBild" runat="server" />--%>
       <asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" OnUploadedComplete="AsyncFileUpload1_OnUploadedComplete" />

       <asp:Button ID="BtnUploadBild" runat="server" Text="LaddaUppBild" onclick="BtnSelectedImage_Click"  />
       <asp:Label ID="lblWarningBild" runat="server"  CssClass="warning" />
   </div>
</asp:Content>

Here is relevant code in code behind for CrimeInvestigator.aspx
***************************************************
protected void AsyncFileUpload1_OnUploadedComplete(object sender, AsyncFileUploadEventArgs e)
     {
         string id = Request.QueryString["ID"];

         //Copy image file to temp katalogen
         AsyncFileUpload1.PostedFile.SaveAs(path + e.FileName);
         path += e.FileName;

         //Upload bild to file ftp server
         FileManager.HandleUpload(path, id);

         //Uppdate datbase with this image file
         backEnd.InsertIntoPictures(id, AsyncFileUpload1.FileName);

         //Refresh page by reading the database Table picture so we can see that the new file has been uploaded
         arendeDetaljUsrCtrl.DisplayCaseDetail(id, "You are loggedin in  as investigator");
     }

Here we have relevant markup for user control ArendeDetails.ascx
*****************************************************
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
               <ContentTemplate
                    <asp:Repeater ID="Repeater2" runat="server" onitemcommand="Repeater1_ItemCommand">
                        <HeaderTemplate>
                           <table id="filer">
                        </HeaderTemplate>

                        <ItemTemplate>
                           <tr>
                              <td>
                                 <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("PName") %>' />
                              </td>
                           </tr>
                        </ItemTemplate>

                        <FooterTemplate>
                           </table>
                        </FooterTemplate>
                    </asp:Repeater>
               </ContentTemplate>
            </asp:UpdatePanel>

Here is relevant code behind for user control ArendeDetails.ascx
***************************************************
This method DisplayCaseDetail is called from method AsyncFileUpload1_OnUploadedComplete in CrimeInvestigator.aspx
public void DisplayCaseDetail(string id, string title)
     {
         lblTitle.Text = title;
         Case myCase = backEnd.GetCaseByID(id);
         this.lblID.Text = myCase.ID;
         this.lblTypeOfCrime.Text = myCase.TypeOfCrime;
         this.lblPlace.Text = myCase.Place;
         this.lblDateTimeOfObservation.Text = myCase.DateOfObservation;
         this.lblInformerName.Text = myCase.InformerName;
         this.lblInformerPhone.Text = myCase.InformerPhone;
         this.lblObservation.Text = myCase.Observation;
         this.lblStatus.Text = myCase.Status;
         this.lblDepartment.Text = myCase.Department;
         this.lblEmployee.Text = myCase.Employee;
         this.lblInfo.Text = myCase.Info;
         this.lblAction.Text = myCase.Action;

         ds = backEnd.GetPictures(lblID.Text);
         if (ds.Tables[0].Rows.Count != 0)
         {
             Repeater2.DataSource = ds;
             Repeater2.DataBind();
         }
         else
         {
             lblBildInfo.Text = "Inga bilder finns upplagda";
         }
     }

So in some way I must be able to to partial update of the repeater2.
I don't really know how I can accomplish this. I have added UpdatePanel just before the Repeater2 control in the user control ArendeDetails.ascx

So any help is appreciated that can help me to accomplish a partial update of the repeater2 control

//Tony

</div>

Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>