Update Panel not refeshing after Callback

Discussion in 'ASP .Net' started by John Kotuby, Dec 3, 2008.

  1. John Kotuby

    John Kotuby Guest

    Hi guys,
    I am using 3rd-party grids in Callback mode. When something in a grid is
    changed and saved by the user, the grid performs a callback to run the
    server code to save the changes and then refresh the grid/s. That's all
    working fine.

    However, I have placed a Label control and a table cell inside of an update
    panel with UpdateMode set to "Always". I want the Label control to display
    an appropriate messsage text according to the current state of the Grids.

    Running in debug mode I see that the code that I have placed in
    Page_PreRender actually seems to run properly during a Callback from the
    grids. However the CallBack is not a postback. Fortunately I rebuild the
    Grids data whether a Postback or Not. How can I update the Label dusing a
    callback? Can I return the Text I want somehow and then apply it on the
    Client side?

    Thanks for any help. The code is below.

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always" >
    <ContentTemplate>
    <table id="Table1" style="position: relative" border="0" width="370px"
    cellspacing="0" cellpadding="0">
    <tr>
    <td valign="top" align="center" colspan="2" style="padding: 4px">
    <asp:Label ID="lblFeedback" runat="server" CssClass="title14"
    ForeColor="#990000" EnableViewState="false"
    Text="Select a Category to Work With" />
    </td>
    </tr>
    <tr style="height: 5px">
    <td runat="server" id="tdMyErrMsg" colspan="2" align="center" style="color:
    red">
    </td>
    </tr>
    </table>
    </ContentTemplate>
    </asp:UpdatePanel>

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.PreRender
    If Page.IsPostBack Then
    buildGrid1()
    buildGridCats()
    End If

    If Grid1.Items.Count = 0 And strCodeId = "" Then
    Me.lblFeedback.Text = "There are No 'Custom Category Groups'. Please Add
    One or More"
    ElseIf GridCats.Items.Count = 0 And strCodeId = "" Then
    Me.lblFeedback.Text = "There are No 'Custom Categories'. Please Add Some
    to Work With"
    ElseIf strCodeId = "" Then
    Me.lblFeedback.Text = "Select a Custom Category to Work With
    (Double-Click)"
    End If

    End Sub
     
    John Kotuby, Dec 3, 2008
    #1
    1. Advertising

  2. John Kotuby

    bruce barker Guest

    a callback is not an update panel postback, and does not return the update
    panels html. for an update panel to work, it must do the postback (as this
    registers the update panels client routines).

    if your gird fire client events, you could force another postback, or do a
    webservice call. if you can turn off the grids callback, then you could put
    it in an update panel if it is properly coded to work in an update panel.

    -- bruce (sqlwork.com)


    "John Kotuby" wrote:

    > Hi guys,
    > I am using 3rd-party grids in Callback mode. When something in a grid is
    > changed and saved by the user, the grid performs a callback to run the
    > server code to save the changes and then refresh the grid/s. That's all
    > working fine.
    >
    > However, I have placed a Label control and a table cell inside of an update
    > panel with UpdateMode set to "Always". I want the Label control to display
    > an appropriate messsage text according to the current state of the Grids.
    >
    > Running in debug mode I see that the code that I have placed in
    > Page_PreRender actually seems to run properly during a Callback from the
    > grids. However the CallBack is not a postback. Fortunately I rebuild the
    > Grids data whether a Postback or Not. How can I update the Label dusing a
    > callback? Can I return the Text I want somehow and then apply it on the
    > Client side?
    >
    > Thanks for any help. The code is below.
    >
    > <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always" >
    > <ContentTemplate>
    > <table id="Table1" style="position: relative" border="0" width="370px"
    > cellspacing="0" cellpadding="0">
    > <tr>
    > <td valign="top" align="center" colspan="2" style="padding: 4px">
    > <asp:Label ID="lblFeedback" runat="server" CssClass="title14"
    > ForeColor="#990000" EnableViewState="false"
    > Text="Select a Category to Work With" />
    > </td>
    > </tr>
    > <tr style="height: 5px">
    > <td runat="server" id="tdMyErrMsg" colspan="2" align="center" style="color:
    > red">
    > </td>
    > </tr>
    > </table>
    > </ContentTemplate>
    > </asp:UpdatePanel>
    >
    > Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles Me.PreRender
    > If Page.IsPostBack Then
    > buildGrid1()
    > buildGridCats()
    > End If
    >
    > If Grid1.Items.Count = 0 And strCodeId = "" Then
    > Me.lblFeedback.Text = "There are No 'Custom Category Groups'. Please Add
    > One or More"
    > ElseIf GridCats.Items.Count = 0 And strCodeId = "" Then
    > Me.lblFeedback.Text = "There are No 'Custom Categories'. Please Add Some
    > to Work With"
    > ElseIf strCodeId = "" Then
    > Me.lblFeedback.Text = "Select a Custom Category to Work With
    > (Double-Click)"
    > End If
    >
    > End Sub
    >
    >
    >
     
    bruce barker, Dec 3, 2008
    #2
    1. Advertising

  3. John Kotuby

    John Kotuby Guest

    Thanks Bruce,

    I appreciate the reply and fogot to thank you yesterday. I am trying to move
    away from the Update Panel method for partial page refresh because it sends
    to much baggage to the server in the form of ViewState on large complicated
    pages. I am just getting the hang of Calbacks and the various ways they are
    implemented, as well as how they relate to other ASP.NET controls like the
    UpdatePanel (where I haven't gotten around to converting them yet).

    I am working on using the Callback_Complete event in the Grids to fire
    another callback to refresh just the displayed maessage, which relies on the
    contents of the Grids.

    Thanks again...

    "bruce barker" <> wrote in message
    news:...
    >a callback is not an update panel postback, and does not return the update
    > panels html. for an update panel to work, it must do the postback (as this
    > registers the update panels client routines).
    >
    > if your gird fire client events, you could force another postback, or do a
    > webservice call. if you can turn off the grids callback, then you could
    > put
    > it in an update panel if it is properly coded to work in an update panel.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "John Kotuby" wrote:
    >
    >> Hi guys,
    >> I am using 3rd-party grids in Callback mode. When something in a grid is
    >> changed and saved by the user, the grid performs a callback to run the
    >> server code to save the changes and then refresh the grid/s. That's all
    >> working fine.
    >>
    >> However, I have placed a Label control and a table cell inside of an
    >> update
    >> panel with UpdateMode set to "Always". I want the Label control to
    >> display
    >> an appropriate messsage text according to the current state of the Grids.
    >>
    >> Running in debug mode I see that the code that I have placed in
    >> Page_PreRender actually seems to run properly during a Callback from the
    >> grids. However the CallBack is not a postback. Fortunately I rebuild the
    >> Grids data whether a Postback or Not. How can I update the Label dusing a
    >> callback? Can I return the Text I want somehow and then apply it on the
    >> Client side?
    >>
    >> Thanks for any help. The code is below.
    >>
    >> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always" >
    >> <ContentTemplate>
    >> <table id="Table1" style="position: relative" border="0" width="370px"
    >> cellspacing="0" cellpadding="0">
    >> <tr>
    >> <td valign="top" align="center" colspan="2" style="padding: 4px">
    >> <asp:Label ID="lblFeedback" runat="server" CssClass="title14"
    >> ForeColor="#990000" EnableViewState="false"
    >> Text="Select a Category to Work With" />
    >> </td>
    >> </tr>
    >> <tr style="height: 5px">
    >> <td runat="server" id="tdMyErrMsg" colspan="2" align="center"
    >> style="color:
    >> red">
    >> </td>
    >> </tr>
    >> </table>
    >> </ContentTemplate>
    >> </asp:UpdatePanel>
    >>
    >> Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
    >> System.EventArgs) Handles Me.PreRender
    >> If Page.IsPostBack Then
    >> buildGrid1()
    >> buildGridCats()
    >> End If
    >>
    >> If Grid1.Items.Count = 0 And strCodeId = "" Then
    >> Me.lblFeedback.Text = "There are No 'Custom Category Groups'. Please
    >> Add
    >> One or More"
    >> ElseIf GridCats.Items.Count = 0 And strCodeId = "" Then
    >> Me.lblFeedback.Text = "There are No 'Custom Categories'. Please Add
    >> Some
    >> to Work With"
    >> ElseIf strCodeId = "" Then
    >> Me.lblFeedback.Text = "Select a Custom Category to Work With
    >> (Double-Click)"
    >> End If
    >>
    >> End Sub
    >>
    >>
    >>
     
    John Kotuby, Dec 4, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harry
    Replies:
    3
    Views:
    560
    Harry Singh
    Nov 10, 2003
  2. HS1
    Replies:
    3
    Views:
    499
  3. HS1
    Replies:
    4
    Views:
    8,325
    Babu Kalakrishnan
    Dec 8, 2004
  4. John Kotuby
    Replies:
    0
    Views:
    369
    John Kotuby
    Aug 18, 2008
  5. Sven Fischer
    Replies:
    0
    Views:
    486
    Sven Fischer
    Oct 22, 2012
Loading...

Share This Page