ajax updatePanel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lisles
    New Member
    • Jan 2010
    • 40

    ajax updatePanel

    Hi.i want to use a ajax updatepanel.on postnack i only want the datalist "dlEvnt" to get refreshed.but thats not happening.can anybody tell me what to do.
    Here's my code

    edit: massive code block removed. --insertAlias
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Is "dlEvnt" (whatever that is) in side the UpdatePanel?

    Comment

    • lisles
      New Member
      • Jan 2010
      • 40

      #3
      yes it is....it is a datalist
      Code:
       <tr>
                                      <td colspan="4" style="width: 540px">
                                          <asp:UpdatePanel ID="updpEvnt" runat="server" UpdateMode="Conditional">
                                              <ContentTemplate>
                                                  <%--OnSelectedIndexChanged="selectedIndexChanged" "--%>
                                                  <table>
                                                      <tr>
                                                          <td>
                                                              <asp:DataList ID="dlEvnt" runat="server" HorizontalAlign="Left" RepeatDirection="Horizontal"
                                                                  BorderColor="#99A866" RepeatColumns="3" GridLines="Both" OnItemCommand="imageSelect"
                                                                  DataKeyField="prison_eventDtl_srno" Visible="false">
                                                                  <ItemTemplate>
                                                                      <table width="100%" onmouseover="dg_changeBackColor(this, true);" onmouseout="dg_changeBackColor(this, false);">
                                                                          <tr>
                                                                              <td align="center" colspan="4">
                                                                                  <asp:ImageButton ID="imgDlEvnt" runat="server" Height="51px" Width="66px" AlternateText="Photo"
                                                                                      BorderColor="Silver" BorderStyle="Solid" ImageAlign="Middle" ImageUrl='<%# "~/ASHX/ImageHandler.ashx?queryType=dl_image&__KEY="+ Eval("prison_event_id")+"&__imgId="+Eval("prison_eventDtl_srno") %>'
                                                                                      CommandName="image" />
                                                                                  <br />
                                                                                  <asp:Label ID="lblImgDesc" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_Description") %>'></asp:Label>
                                                                                  <asp:Label ID="lblEvntId" runat="server" Visible="false" Text='<%# Bind("prison_event_id") %>'></asp:Label>
                                                                                  <asp:Label ID="lblImgSrno" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_srno") %>'></asp:Label>
                                                                                  <asp:Label ID="lblImgYn" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_activeYN") %>'></asp:Label>
                                                                                  &nbsp; &nbsp;
                                                                              </td>
                                                                          </tr>
                                                                      </table>
                                                                  </ItemTemplate>
                                                              </asp:DataList></td>
                                                      </tr>
                                                  </table>
                                              </ContentTemplate>
                                              <Triggers>
                                                  <asp:AsyncPostBackTrigger ControlID="dlEvnt" EventName="ItemCommand" />
                                              </Triggers>
                                          </asp:UpdatePanel>
                                      </td>
                                  </tr>

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Well that's good but you haven't given us very much information to help you with. I have no idea why your list isn't getting refreshed because I can't guess what you're doing in code to refresh the list.

        If you provide us with more information about your application and perhaps if you posted some code that pertains to the problem we could help you further.

        -Frinny

        Comment

        • lisles
          New Member
          • Jan 2010
          • 40

          #5
          Originally posted by Frinavale
          Well that's good but you haven't given us very much information to help you with. I have no idea why your list isn't getting refreshed because I can't guess what you're doing in code to refresh the list.

          If you provide us with more information about your application and perhaps if you posted some code that pertains to the problem we could help you further.

          -Frinny
          this is my onItemCommand code for the datalist
          Code:
          protected void imageSelect(object source, DataListCommandEventArgs e)
              {
                  dlEvnt.SelectedIndex = e.Item.ItemIndex;
                  // string id = dlEvnt.DataKeys[dlEvnt.SelectedIndex].ToString();
                  BLL_NewsAndEvents objNE = new BLL_NewsAndEvents();
                  objNE.Id = dlEvents.DataKeys[dlEvents.SelectedIndex].ToString();
                  objNE.Key = dlEvnt.DataKeys[dlEvnt.SelectedIndex].ToString();
          
                  //objNE.title = dlEvents.DataKeys[dlEvents.SelectedIndex].ToString();
          
                  //objNE.getEvntDetails();
                  objNE.getNewImage();
                  if (objNE.tests)
                  {
                      if (objNE.imgDtlYn == "Y")
                      {
                          btniEvntDtlImg.ImageUrl = "~/ASHX/ImageHandler.ashx?queryType=dl_image&__KEY=" + objNE.Id + "&__imgId=" + objNE.Key;
                      }
                      else
                      {
                          btniEvntDtlImg.Visible = false;
                          lblEvntDtlDesc.Visible = false;
                          //btniEvntDtlImg.ImageUrl = "~/images/noPhoto.jpg";
                      }
          
                  }
                  lblEvntDtlDesc.Text = objNE.imgDesc.ToString();
                  objNE.Close();
              [B]    this.updpEvnt.Update();[/B]    }
          the highlited part is where im calin the update function for the panel
          anything else you want me to post?

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            I've never explicitly called the UpdatePanel.Upd ate method before. Apparently this method is called for you automatically in the page life cycle.

            Is there any reason in particular that you are taking this approach?

            I recommend commenting out that line for now....

            -Frinny

            Comment

            • lisles
              New Member
              • Jan 2010
              • 40

              #7
              Originally posted by Frinavale
              I've never explicitly called the UpdatePanel.Upd ate method before. Apparently this method is called for you automatically in the page life cycle.

              Is there any reason in particular that you are taking this approach?

              I recommend commenting out that line for now....

              -Frinny
              i commented out the line...but still no difference.the whole page is still getting refreshed

              Comment

              • lisles
                New Member
                • Jan 2010
                • 40

                #8
                i tried puttin the panel in a seperate table also as follows:
                Code:
                  <div style="width: 550px; float: left;">
                                           <asp:UpdatePanel ID="updpEvnt" runat="server" UpdateMode="Conditional">
                                                        <ContentTemplate>
                                          <table>
                                            <tr>
                                                <td colspan="4" style="width: 540px">
                                                   
                                                           
                                                            <table>
                                                                <tr>
                                                                    <td>
                                                                        <asp:DataList ID="dlEvnt" runat="server" HorizontalAlign="Left" RepeatDirection="Horizontal"
                                                                            BorderColor="#99A866" RepeatColumns="3" GridLines="Both" OnItemCommand="imageSelect"
                                                                            DataKeyField="prison_eventDtl_srno" Visible="false">
                                                                            <ItemTemplate>
                                                                                <table width="100%" onmouseover="dg_changeBackColor(this, true);" onmouseout="dg_changeBackColor(this, false);">
                                                                                    <tr>
                                                                                        <td align="center" colspan="4">
                                                                                            <asp:ImageButton ID="imgDlEvnt" runat="server" Height="51px" Width="66px" AlternateText="Photo"
                                                                                                BorderColor="Silver" BorderStyle="Solid" ImageAlign="Middle" ImageUrl='<%# "~/ASHX/ImageHandler.ashx?queryType=dl_image&__KEY="+ Eval("prison_event_id")+"&__imgId="+Eval("prison_eventDtl_srno") %>'
                                                                                                CommandName="image" />
                                                                                            <br />
                                                                                            <asp:Label ID="lblImgDesc" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_Description") %>'></asp:Label>
                                                                                            <asp:Label ID="lblEvntId" runat="server" Visible="false" Text='<%# Bind("prison_event_id") %>'></asp:Label>
                                                                                            <asp:Label ID="lblImgSrno" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_srno") %>'></asp:Label>
                                                                                            <asp:Label ID="lblImgYn" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_activeYN") %>'></asp:Label>
                                                                                            &nbsp; &nbsp;
                                                                                        </td>
                                                                                    </tr>
                                                                                </table>
                                                                            </ItemTemplate>
                                                                        </asp:DataList></td>
                                                                </tr>
                                                            </table>
                                                      
                                                </td>
                                            </tr>
                                            </table>
                                              </ContentTemplate>
                                                        <Triggers>
                                                            <asp:AsyncPostBackTrigger ControlID="dlEvnt" EventName="ItemCommand" />
                                                        </Triggers>
                                                    </asp:UpdatePanel>
                                                    </div>

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  Oh I think I know what you're having problems with.
                  Just put the "dlEvnt" inside it's own UpdatePanel within the other UpdatePanel.

                  Comment

                  • lisles
                    New Member
                    • Jan 2010
                    • 40

                    #10
                    Originally posted by Frinavale
                    Oh I think I know what you're having problems with.
                    Just put the "dlEvnt" inside it's own UpdatePanel within the other UpdatePanel.
                    can you tell me how.i did the following
                    Code:
                              <div style="width: 550px; float: left;">
                                               <asp:UpdatePanel ID="updpEvnt" runat="server" UpdateMode="Conditional">
                                                            <ContentTemplate>
                                              <table>
                                                <tr>
                                                    <td colspan="4" style="width: 540px">
                                                       
                                                                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                                            <ContentTemplate>
                                                                <table>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:DataList ID="dlEvnt" runat="server" HorizontalAlign="Left" RepeatDirection="Horizontal"
                                                                                BorderColor="#99A866" RepeatColumns="3" GridLines="Both" OnItemCommand="imageSelect"
                                                                                DataKeyField="prison_eventDtl_srno" Visible="false">
                                                                                <ItemTemplate>
                                                                                    <table width="100%" onmouseover="dg_changeBackColor(this, true);" onmouseout="dg_changeBackColor(this, false);">
                                                                                        <tr>
                                                                                            <td align="center" colspan="4">
                                                                                                <asp:ImageButton ID="imgDlEvnt" runat="server" Height="51px" Width="66px" AlternateText="Photo"
                                                                                                    BorderColor="Silver" BorderStyle="Solid" ImageAlign="Middle" ImageUrl='<%# "~/ASHX/ImageHandler.ashx?queryType=dl_image&__KEY="+ Eval("prison_event_id")+"&__imgId="+Eval("prison_eventDtl_srno") %>'
                                                                                                    CommandName="image" />
                                                                                                <br />
                                                                                                <asp:Label ID="lblImgDesc" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_Description") %>'></asp:Label>
                                                                                                <asp:Label ID="lblEvntId" runat="server" Visible="false" Text='<%# Bind("prison_event_id") %>'></asp:Label>
                                                                                                <asp:Label ID="lblImgSrno" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_srno") %>'></asp:Label>
                                                                                                <asp:Label ID="lblImgYn" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_activeYN") %>'></asp:Label>
                                                                                                &nbsp; &nbsp;
                                                                                            </td>
                                                                                        </tr>
                                                                                    </table>
                                                                                </ItemTemplate>
                                                                            </asp:DataList></td>
                                                                    </tr>
                                                                </table>
                                                          </ContentTemplate>
                                                            <Triggers>
                                                                <asp:AsyncPostBackTrigger ControlID="dlEvnt" EventName="ItemCommand" />
                                                            </Triggers>
                                                        </asp:UpdatePanel>
                                                    </td>
                                                </tr>
                                                </table>
                                                  </ContentTemplate>
                                                            <%--<Triggers>
                                                                <asp:AsyncPostBackTrigger ControlID="dlEvnt" EventName="ItemCommand" />
                                                            </Triggers>--%>
                                                        </asp:UpdatePanel>
                                                        </div>

                    i even removed the trigger of the outerpanel and tried but still no luck at all

                    Comment

                    • Frinavale
                      Recognized Expert Expert
                      • Oct 2006
                      • 9749

                      #11
                      Strange, I figured that because you previously added an UpdatePanel you'd be able to add a nested one inside it.

                      Anyways, try this:
                      Code:
                      <div style="width: 550px; float: left;">
                      <%--<asp:UpdatePanel ID="updpEvnt" runat="server">
                      <ContentTemplate>--%>
                          <table>
                              <tr>
                                  <td colspan="4" style="width: 540px">
                                      <asp:UpdatePanel ID="dlEvntUpdate" runat="server">
                                      <ContentTemplate>
                                          <table>
                                              <tr>
                                                  <td>
                                                      <asp:DataList ID="dlEvnt" runat="server" HorizontalAlign="Left" RepeatDirection="Horizontal"
                                                          BorderColor="#99A866" RepeatColumns="3" GridLines="Both" OnItemCommand="imageSelect"
                                                          DataKeyField="prison_eventDtl_srno" Visible="false">
                                                          <ItemTemplate>
                                                              <table width="100%" onmouseover="dg_changeBackColor(this, true);" onmouseout="dg_changeBackColor(this, false);">
                                                                  <tr>
                                                                      <td align="center" colspan="4">
                                                                          <asp:ImageButton ID="imgDlEvnt" runat="server" Height="51px" Width="66px" AlternateText="Photo"
                                                                              BorderColor="Silver" BorderStyle="Solid" ImageAlign="Middle" ImageUrl='<%# "~/ASHX/ImageHandler.ashx?queryType=dl_image&__KEY="+ Eval("prison_event_id")+"&__imgId="+Eval("prison_eventDtl_srno") %>'
                                                                              CommandName="image" />
                                                                          <br />
                                                                          <asp:Label ID="lblImgDesc" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_Description") %>'></asp:Label>
                                                                          <asp:Label ID="lblEvntId" runat="server" Visible="false" Text='<%# Bind("prison_event_id") %>'></asp:Label>
                                                                          <asp:Label ID="lblImgSrno" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_srno") %>'></asp:Label>
                                                                          <asp:Label ID="lblImgYn" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_activeYN") %>'></asp:Label>
                                                                          &nbsp; &nbsp;
                                                                      </td>
                                                                  </tr>
                                                              </table>
                                                          </ItemTemplate>
                                                      </asp:DataList>
                                                  </td>
                                              </tr>
                                          </table>
                                      </ContentTemplate>
                                      </asp:UpdatePanel>
                                  </td>
                              </tr>
                          </table>
                      <%--</ContentTemplate>--%>
                      <%--<Triggers>
                          <asp:AsyncPostBackTrigger ControlID="dlEvnt" EventName="ItemCommand" />
                      </Triggers>--%>
                      <%--</asp:UpdatePanel>--%>
                      </div>
                      (PS. You should not be using tables to format the look and feel of your web page.)

                      Comment

                      • lisles
                        New Member
                        • Jan 2010
                        • 40

                        #12
                        Originally posted by Frinavale
                        Strange, I figured that because you previously added an UpdatePanel you'd be able to add a nested one inside it.

                        Anyways, try this:
                        Code:
                        <div style="width: 550px; float: left;">
                        <%--<asp:UpdatePanel ID="updpEvnt" runat="server">
                        <ContentTemplate>--%>
                            <table>
                                <tr>
                                    <td colspan="4" style="width: 540px">
                                        <asp:UpdatePanel ID="dlEvntUpdate" runat="server">
                                        <ContentTemplate>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <asp:DataList ID="dlEvnt" runat="server" HorizontalAlign="Left" RepeatDirection="Horizontal"
                                                            BorderColor="#99A866" RepeatColumns="3" GridLines="Both" OnItemCommand="imageSelect"
                                                            DataKeyField="prison_eventDtl_srno" Visible="false">
                                                            <ItemTemplate>
                                                                <table width="100%" onmouseover="dg_changeBackColor(this, true);" onmouseout="dg_changeBackColor(this, false);">
                                                                    <tr>
                                                                        <td align="center" colspan="4">
                                                                            <asp:ImageButton ID="imgDlEvnt" runat="server" Height="51px" Width="66px" AlternateText="Photo"
                                                                                BorderColor="Silver" BorderStyle="Solid" ImageAlign="Middle" ImageUrl='<%# "~/ASHX/ImageHandler.ashx?queryType=dl_image&__KEY="+ Eval("prison_event_id")+"&__imgId="+Eval("prison_eventDtl_srno") %>'
                                                                                CommandName="image" />
                                                                            <br />
                                                                            <asp:Label ID="lblImgDesc" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_Description") %>'></asp:Label>
                                                                            <asp:Label ID="lblEvntId" runat="server" Visible="false" Text='<%# Bind("prison_event_id") %>'></asp:Label>
                                                                            <asp:Label ID="lblImgSrno" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_srno") %>'></asp:Label>
                                                                            <asp:Label ID="lblImgYn" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_activeYN") %>'></asp:Label>
                                                                            &nbsp; &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </ItemTemplate>
                                                        </asp:DataList>
                                                    </td>
                                                </tr>
                                            </table>
                                        </ContentTemplate>
                                        </asp:UpdatePanel>
                                    </td>
                                </tr>
                            </table>
                        <%--</ContentTemplate>--%>
                        <%--<Triggers>
                            <asp:AsyncPostBackTrigger ControlID="dlEvnt" EventName="ItemCommand" />
                        </Triggers>--%>
                        <%--</asp:UpdatePanel>--%>
                        </div>
                        (PS. You should not be using tables to format the look and feel of your web page.)
                        still not working:(

                        Comment

                        • Frinavale
                          Recognized Expert Expert
                          • Oct 2006
                          • 9749

                          #13
                          I don't know why it's not working.

                          Are you sure you are calling the method that updates the list? How is the page being posted back to the server so that the list can be updated?

                          That control, that causes the page to post back to the server, must be within the same UpdatePanel as the list. If it's outside the UpdatePanel then the whole page will post back.

                          -Frinny

                          Comment

                          • lisles
                            New Member
                            • Jan 2010
                            • 40

                            #14
                            Originally posted by Frinavale
                            I don't know why it's not working.

                            Are you sure you are calling the method that updates the list? How is the page being posted back to the server so that the list can be updated?

                            That control, that causes the page to post back to the server, must be within the same UpdatePanel as the list. If it's outside the UpdatePanel then the whole page will post back.

                            -Frinny
                            do you want me 2 post my entire code?

                            Comment

                            • Frinavale
                              Recognized Expert Expert
                              • Oct 2006
                              • 9749

                              #15
                              Nope, it's hard to read full code posts. You should only post what is relevant to your problem :)

                              Now, the control that is responsible for posting back to the server is relevant to your problem so it would be helpful if you either pointed out where that control is in your current posted code or if you posted your code and included this control.

                              Comment

                              Working...