Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Show Hide DIV or Panel after Postback

Posted on 2011-02-28
11
Medium Priority
?
5,000 Views
Last Modified: 2012-05-11
I am having difficulty showing a hidden DIV or ASP.net Panel on postback.

I submit a page that adds items to a database then sends an email.  Those items work perfect.  However, I want a message to show up saying that it was successful.  My understanding from what I have read is that if you are using a Panel with visibility set to False that it will not be rendered, therefore you cannot set it back to visibile from the server side.  

I've also tried setting the DIV style via javascript and have not been successful.

As the insert to the database takes place an ajax update panel does show.  But for some reason the portion to show the "success" message  will not trigger.

I know that I am rambling, but just frustrated.

Here is the portion that should show after the insert and email "Success Message":
(currently set for trying to change the style. Tried visibility:hidden/visible too)
 
<div id="SubmittedPanelWrapper" runat="server" style="display: block" >
             <div id="SubmittedBackgroundFilter"></div>
            <div id="SubmittedMessage"> 
                
                         <center> 
                          The change has been submitted.<br /> You will receive an email once the change is complete.<br /> <br />
                             <asp:Button ID="SubmittedOK" runat="server" Text="OK" CssClass="submitButton" />
                         </center> 
                            </div>
                         </div>

Open in new window


Associated CSS for the Success Message:
 
#SubmittedBackgroundFilter {
    position:fixed;
    top:0px;
    bottom:0px;
    left:0px;
    right:0px;
    overflow:hidden;
    padding:0;
    margin:0;
    background-color:#000;
    filter:alpha(opacity=50);
    opacity:0.5;
    z-index:1000;
}#SubmittedMessage {
    position:fixed;
    top:30%;
    left:43%;
    padding:10px;
    width:14%;
    z-index:1001;
    background-color:#fff;
    border:solid 1px #000;
}
.submitButton
{
    text-align: right;
    padding-right: 10px;
}

Open in new window



The submit button (visibile set to true from code behind once certain criteria are met, works):
 
<asp:Button ID="SubmitButton" runat="server" Text="Submit Changes"  
                style="text-align: center" Visible="false" 
                "/>

Open in new window


The Sub:
 
Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
        SqlDataSourceInsertClientUpdate.Insert() ' <- Works 
        SendIANotificationEmail()  ' <- Works
        ' This is where I would set a trigger to show the "Success" Message
        ' I've tried SubmittedPanelWrapper.Style.Add("display", "block")
        ' I've tried this with a panel as well.
        ' I've tried PanelChangeSubmitted.visible = True  ** The panel code is no longer in the aspx page.  But this is how I tried to activate it when it was.
        ' I've tried setting the style by javascript and using the onClientClick.

    End Sub

Open in new window


I have even setup a new asp button and tried to trigger off of it, thinking it had something to do with the timing of the postback.  But it didn't work either.

Any help in the right direction would be appreciated.
0
Comment
Question by:ITMcmcpa
  • 6
  • 4
11 Comments
 
LVL 5

Expert Comment

by:sindhuxyz
ID: 34999640
If you want to control  <div id="SubmittedMessage">  from code behind for visibility then add runat="server" tag, you will be able to access div from code behind.

 <div id="SubmittedMessage" runat="server">


code behind
---------------

SubmittedMessage.visible=false
0
 

Author Comment

by:ITMcmcpa
ID: 34999710
Unfortunately that does not work. SubmittedPanelWrapper has the runat="server" and I can access the visibile attribute from the Code Behind, but it does not trigger.  There is no error message.
0
 
LVL 5

Expert Comment

by:sindhuxyz
ID: 34999836
Please post code where you have made panel's visibility false/true and also your page_load event too.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ITMcmcpa
ID: 34999936
This is how I tried setting up the panel:
 
<asp:Panel ID="PanelChangeSubmitted" runat="server" Visible="false">
     <div id="SubmittedPanelWrapper" runat="server" >
             <div id="SubmittedBackgroundFilter"></div>
            <div id="SubmittedMessage"> 
                
                         <center> 
                          The change has been submitted.<br /> You will receive an email once the change is complete.<br /> <br />
                             <asp:Button ID="SubmittedOK" runat="server" Text="OK" CssClass="submitButton" />
                         </center> 
                            </div>
                         </div>
                         </asp:Panel>

Open in new window


The Submit Button:
 
Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
        SqlDataSourceInsertClientUpdate.Insert() ' <- Works 
        SendIANotificationEmail()  ' <- Works
        PanelChangeSubmitted.Visible = True ' <-doesn't work
    End Sub

Open in new window


page_load:
 
'set logged in user for credential validation
      


        Dim CurrentUserName As String = Environment.UserName
        Try
            TBUser.Text = Session("loggedinas").ToString()
        Catch ex As Exception
            Response.Redirect("~/sessionint.aspx")
        End Try


        ' PanelChangeSubmitted.Visible = False
        LBLloggedInUserCPaaa.Text = CurrentUserName
        LBLwarning1aaa.Visible = True
        TBDateTimeofEntry.Text = Now()

        SetWarningLabel()



        'set title of page in the site.master
        Dim myLabel As Label
        myLabel = CType(Master.FindControl("LBLHeaderTitle"), Label)
        If Not myLabel Is Nothing Then

            myLabel.Text = "Client Update Form"
        End If



        'lookup rights for viewing update client list link

        Dim dvSqlCUlist As DataView =
       DirectCast(SqlDataSource4AccessClientUpdateList.Select(DataSourceSelectArguments.Empty), DataView)
        For Each drvSqlCUlist As DataRowView In dvSqlCUlist
            If drvSqlCUlist("userclientupdatelist").ToString() = "True" Then


                ListViewerHyperLink.Visible = True

            Else

                ListViewerHyperLink.Visible = False
            End If

        Next

    End Sub

Open in new window

0
 
LVL 5

Expert Comment

by:sindhuxyz
ID: 35000135
can you try like below

// To hide:
 Panel1.Style.Add("display", "none");
// To show:
 Panel1.Style.Add("display", "block");
0
 

Author Comment

by:ITMcmcpa
ID: 35000144
I've tried it once.. but I will try again.
0
 
LVL 5

Expert Comment

by:sindhuxyz
ID: 35000158
before you try above; remove Visible="false" from panel
0
 

Author Comment

by:ITMcmcpa
ID: 35000160
right
0
 

Author Comment

by:ITMcmcpa
ID: 35000189
I put the hide in the page load.  It does hide the panel.  But the show does not work.
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 35000230
You said you are using UpdatePanel correct? So if your postback is coming from UP and your message panel is outside of that panel, it won't be update. Make sure your MessagePanel is also inside of UP.
If that is not the case let us know.
0
 

Author Comment

by:ITMcmcpa
ID: 35000245
That was exactly it.  It works now.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question