Postback causes Javascipted button to disappear

Posted on 2010-11-08
Last Modified: 2012-05-10
Hello, I have a webuser control on a page that resides in an update panel. In this control I have two calendar controls that have their autopostback = true, so I can capture the selected date and perform some functions.

My control searches a database for blog posts for the timespan of the two calendar controls. Once the results are displayed in my gridview control, I have a facebook share button so users can share the blog post on their facebook wall.

This all works perfectly if the dates are manually set and the calendar controls are not used. If the calendar controls are used the facebook share button disappears.

Attached is my control. How can I over come this issue???

Sorry for the long code example. The facebook link and javascript is near the bottom.
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="SearchPostIt.ascx.vb"
    Inherits="Controls_Site_SearchPostIt" %>
<%@ Register TagPrefix="obout" Namespace="OboutInc.Calendar2" Assembly="obout_Calendar2_Net" %>
<%@ Register TagPrefix="obout" Namespace="OboutInc.Editor" Assembly="obout_Editor" %>

   <asp:ScriptManager runat="server" ID="scriptmgr">
                <asp:UpdatePanel ID="upJoin" runat="server">
<h4 class="heading colr">
    Search Post It!</h4>
<div id="search_PostItControls">
    Start Date&nbsp;
    <obout:Calendar runat="server" ID="calStartDate" DatePickerImagePath="~/Controls/Calendar_data/icon2.gif"
        DatePickerMode="true" StyleFolder="~/Controls/Calendar_data/blue/" TextBoxId="txtStart"
        DatePickerSynchronize="true" DateMin="2000-01-01" AutoPostBack="true">
        <asp:Label runat="server" ID="lblStartDate"></asp:Label></strong> End Date&nbsp;
    <obout:Calendar runat="server" ID="calEndDate" DatePickerImagePath="~/Controls/Calendar_data/icon2.gif"
        DatePickerMode="true" StyleFolder="~/Controls/Calendar_data/blue/" TextBoxId="txtEnd"
        DatePickerSynchronize="true" DateMin="2000-01-01"  AutoPostBack="true">
    &nbsp;&nbsp;&nbsp; <strong>
        <asp:Label runat="server" ID="lblEndDate"></asp:Label></strong>&nbsp;&nbsp;&nbsp;
    <asp:LinkButton runat="server" ID="ibtnSearch" Text="Search Posts" TabIndex="1" class="simplebtn"></asp:LinkButton>
<div class="clear">
<asp:LinkButton runat="server" ID="lbRecentPosts" Text="Recent Posts" PostBackUrl="~/Default.aspx"
<asp:GridView runat="server" ID="gvPostIts" AutoGenerateColumns="false" GridLines="None">
                <div id="PostIt">
                    <div id="PostIt_Left">
                        <a style="text-decoration: underline; font-weight: bold" rel="shadowbox;options{dimensions:height=800;width=790}"
                            id="lbMemberLink" href='<%# "Member.aspx?UserId=" & eval("UserId") %>'>
                            <img src="<%#"Images/Members/Profile/" & Eval("smPhoto") %>" alt="<%# Eval("Fullname") %>"
                                style="border: none" />
                    <div id="PostIt_Right">
                        <div class="postIt_Title">
                                <%# Eval("Fullname") %></h6>
                            <span class="postIt_Date">
                                <%# Eval("Created") %></span> <span class="postIt_Delete">
                                    <asp:LinkButton runat="server" ID="lbDeletePostIt" Text="X" CommandName="Select"
                                        class="simplebtn" OnClick="lbDeletePostIt_Click"></asp:LinkButton>
                        <div class="clear">
                        <div class="postIt_Comment">
                            <%# Eval("Comment") %>
                        <asp:Label ID="lblPostItId" runat="server" Text='<%# Eval("PostItId") %>' Visible="false" />
                    <div class="clear">
                    <asp:GridView runat="server" ID="gvComments" AutoGenerateColumns="false" GridLines="None"
                                    <div id="PostItComment_Left">
                                        <a style="text-decoration: underline; font-weight: bold" rel="shadowbox;options{dimensions:height=800;width=790}"
                                            id="lbMemberLink" href='<%# "Member.aspx?UserId=" & eval("UserId") %>'>
                                            <img src="<%#"Images/Members/Profile/" & Eval("smPhoto") %>" alt="<%# Eval("Fullname") %>"
                                                style="border: none" />
                                    <div id="PostItComment_Right">
                                        <div class="postItComment_Title">
                                                <%# Eval("Fullname") %></h6>
                                            <span class="postItComment_Date">
                                                <%# Eval("Created") %></span> <span class="postItComment_Delete">
                                                    <asp:LinkButton runat="server" ID="lbDeletePostItComment" Text="X" CommandName="Select"
                                                        class="simplebtn" OnClick="lbDeletePostItComment_Click"></asp:LinkButton></span>
                                        <div class="clear">
                                        <div class="postItComment_comment">
                                        <asp:Label ID="lblPostItCommentId" runat="server" Text='<%# Eval("PostItCommentId") %>'
                                            Visible="false" />
                    <div id="postItNewComment">
                        <asp:Panel runat="server" ID="pnlComment">
                            <div style="margin: 20px 0px 10px 60px; height: 150px;">
                                <obout:Editor ID="ed_Comment" runat="server" PathPrefix="~/Controls/editor_data/"
                                    ShowQuickFormat="false" ModeSwitch="false" Submit="False" Appearance="custom"
                                    Height="120" Width="550" ClientValidation="true" AutoFocus="false" AjaxWait="false">
                                        <obout:Toggle Name="Bold" />
                                        <obout:Toggle Name="Italic" />
                                        <obout:Toggle Name="Underline" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="ForeColor" />
                                        <obout:Method Name="ForeColorClear" />
                                        <obout:Method Name="BackColor" />
                                        <obout:Method Name="BackColorClear" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="ClearStyles" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="Print" />
                                        <obout:Method Name="SpellCheck" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="OrderedList" />
                                        <obout:Method Name="BulletedList" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="ToLowerCase" />
                                        <obout:Method Name="ToUpperCase" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="SelectAll" />
                                        <obout:Method Name="SelectNone" />
                                        <obout:Method Name="Cut" />
                                        <obout:HorizontalSeparator />
                                        <obout:Method Name="CreateLink" />
                                <div class="commentButtons">
                                    <asp:LinkButton runat="server" ID="ibtnAddComment" Text="Comment" TabIndex="1" ValidationGroup="comment"
                                        class="simplebtn" OnClick="ibtnAddComment_Click"></asp:LinkButton>
                                    <asp:LinkButton runat="server" ID="lbCancelComment" Text="Cancel" class="simplebtn"
                                    <asp:RequiredFieldValidator CssClass="req" ID="rfvComment" runat="server" ControlToValidate="ed_Comment"
                                        ErrorMessage="Comment Required" ValidationGroup="comment"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator CssClass="req" ID="refComment" runat="server" ControlToValidate="ed_Comment"
                                        ErrorMessage="8000 Characters Max" ValidationExpression="^(.|\n){0,8000}$" ValidationGroup="comment"></asp:RegularExpressionValidator>
                                    <asp:Literal runat="server" ID="CommentErrorMessage"></asp:Literal>
                                    &nbsp;&nbsp;<asp:LinkButton runat="server" ID="lbCommentLogin" Text="Login" class="simplebtn"
                        <div class="clear">
                        <div class="postIt_links">
                            <div class="postIt_NewComment">
                                <asp:LinkButton runat="server" ID="ibtnComment" Text="Comment" CommandName="Select"
                                    class="simplebtn" OnClick="ibtnComment_Click"></asp:LinkButton>
                                Comments (<%# Eval("Rcount") %>)&nbsp; Like (<%# Eval("Like") %>)&nbsp;
                                <asp:LinkButton runat="server" ID="lbLike" Text="Like" CommandName="Select" OnClick="lbLike_Click"
                                    CssClass="postItButton" Font-Underline="true"></asp:LinkButton>&nbsp;&nbsp;
                                Dislike (<%# Eval("Dislike") %>)&nbsp;
                                <asp:LinkButton runat="server" ID="lbDislike" Text="Dislike" CommandName="Select"
                                    OnClick="lbDisLike_Click" CssClass="postItButton" Font-Underline="true"></asp:LinkButton>&nbsp;&nbsp;
                            <div class="postIt_ShareOS">
                                <a style="text-decoration: underline; font-weight: bold" rel="shadowbox;options{dimensions:height=370;width=640}"
                                    id="hypOpenShare" href='<%# "SharePostIt.aspx?PostItId=" & Eval("PostItId") %>'>
                                    <img src="Images/openshareicon.gif" alt="Open Share Icon" style="border: none" />
                            <div class="postIt_ShareFB">
                                <a name="fb_share" type="icon" share_url='<%# "SharePostIt.aspx?PostItId=" & Eval("PostItId") %>'>

                                <script src="" type="text/javascript">


Open in new window

Question by:gogetsome

Accepted Solution

Tasneem earned 500 total points
ID: 34090157
this looks like you are resetting something on the Page_OnLoad without considering the isPostback as true

Author Comment

ID: 34113747

This is my page load:

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            lbLogin.Visible = False
        End If

The facebook icon disappears for any partial postback. For example, if I add a post and then GetPostItForThreeDays()
it dissapears. GetPostItForThreeDays() does repopulate the gridview that contains the facebook icon(the java button).

Is there a way to reset the javascripted button when I execute a partial postback?

    End Sub


Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
consuming an asmx web service in winforms application 3 37
Interview questions for support of a legacy ASP.NET site 4 56
Connection String 16 54
SQL Exceptions 3 43
In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: (…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

816 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now