Good afternoon everyone!

I'm running into a small snag and it could just be because it's late and I'm not thinking clearly.

I have an ASP Panel that is an alert box. The panel's initial visible property is set to false and should only be set to true when specific events happen and my ShowAlert(string message) method is called.
Everything works great except that when the page posts back the alert re-appears when it shouldn't. This is because the ShowAlert(string message) method sets the visible property to "true" but nothing ever sets it to false again.

The alert box can be dismissed when the user clicks the X button, but the problem is, I'm not sure how to use that click event to change the visible status of the panel. The other issue is since the alert isn't modal, the user can simply ignore the message and perform other events that cause a postpack, causing the message to stay.

Is there a way to essentially "show" a panel and then "hide" it the next time a postback occurs? I know I could check for a postback and just set the visible property to false, but if I do that it may prevent the alert from showing when it needs to show.

Confusing I'm sure.

Here's the HTML for my alert box:

<asp:Panel ID="PanelAlert" runat="server" CssClass="alert alert-warning alert-dismissible fade in" role="alert" data-spy="affix" Visible="False"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> 
    <asp:Literal ID="LiteralAlertMessage" runat="server"></asp:Literal>

and the method that shows the alert:

    /// <summary>
    /// Updates the AlertMessage on the page's alert and shows the alert box.
    /// </summary>
    /// <param name="message">The message to show in the alert box.</param>
    private void ShowAlert(string message)
        PanelAlert.Visible = true;
        LiteralAlertMessage.Text = message;

The events that cause the ShowAlert(string message) method to be called are events in a SqlDataSource's Update and Insert events.

Any suggestions?


I simply disabled the viewstate mode for the panel and it works fine now :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.