Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Panel contents reverting to values in the ASPX file

Status
Not open for further replies.

tomouse

Technical User
Aug 30, 2010
50
I think maybe this is one I've been staring at too long. I have many pages based on the same structure. This includes a panel which is set to visible=false most of the time. When user carries out an update operation, the panel is made visible and an image and a label are set to reflect the result of the update (success or failure).

In all but one of my pages this works fine. However, in the page I've been working on most recently, the text and ImageURL of the items contained within the panel keep reverting back to the values that are set at design-time in the aspx file. Here is the panel:
Code:
        <asp:Panel runat="server" ID="pnlResultado" Visible="false" >
            <div id="DivResultado">
                <asp:Image ID="imgAlerta" runat="server" />
                <asp:Label ID="lblResultado" text="**resulttext**" runat="server"></asp:Label>
            </div>
        </asp:Panel>
So I put a watch on the text value of the label as it is set in the code after the update - everything seems fine (the watch shows that lblResultado.text = "Update completed successfully"). But then when the code is finished and the page displays, the text has reverted back to the value originally set at design time ("**resulttext**").

If I include a blank asp:button (outside of the panel) and click it to force a postback, the label then shows as the desired "Update completed successfully". What is going on here?
 
post the relevant code in your page_load as well the code(event) where you set the label text and imageURL
 
The label and image are passed to a Shared Sub in 'utility class (so that all the pages can use it):
Code:
        Public Shared Sub AtualizaAlerta(ByRef img As Image, ByRef lbl As Label, ByVal bAlertaSucesso As Boolean)

            If bAlertaSucesso Then
                img.ImageUrl = "~/img/ico_alerta_sucesso.gif"
                lbl.Text = Resources.LocalizedText.actioncompletedsuccess
                lbl.CssClass = "AlertaSucesso"
            Else
                img.ImageUrl = "~/img/ico_alerta_erro.gif"
                lbl.Text = Resources.LocalizedText.actionfailed
                lbl.CssClass = "AlertaErro"
            End If

        End Sub
After the updates are called, a sub to set the various panels' visibility is called:
Code:
Visualizar("Resultado")
Here is the relevant section of that:
Code:
    Public Sub Visualizar(ByVal sPainel)
        pnlAlertaFormIntegridade.Visible = False

        Select Case sPainel
'...
            Case "Resultado"
                If viewerType = "Agent" Then
                    imgTopo.ImageUrl = Resources.LocalizedText.imgbannerAgentJourneys
                Else
                    imgTopo.ImageUrl = Resources.LocalizedText.imgbannerManagerJourneys
                End If
                pnlListarViagens.Visible = False
                pnlViagem.Visible = False
                pnlResultado.Visible = True
'...
 
You need to post all the code in order for us to see the flow of the code. There is something wrong with the logic somewhere, so I suggest you trace through you code to find the issue. If you still cannot find it, post all the relevant code, including the page_load event.
 
Yes, I understand. I was reluctant to do that as I know what my reaction is when someone posts in a huge chunk of code accompanied by a qustion! I'll work through the code again and see if I've missed anything. Thanks, Tom
 
if you have to post that much code, it could be the sign of a design flaw. at the very least a candidate for refactoring. if you can separate your code from dependencies on asp.net and webforms you could automate some tests for you code to simplify finding the bug and reducing the chance of introducing new bugs.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Yes, definitely a candidate for refactoring. An inherited system that I've had to pick up quickly and add a whole load of new functionality. When I have some spare time (ha!) I'll get on it! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top