troubleshooting Question

Postback causes Javascipted button to disappear

Avatar of gogetsome
gogetsomeFlag for United States of America asked on
.NET Programming
2 Comments1 Solution1089 ViewsLast Modified:
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:ScriptManager>
                <asp:UpdatePanel ID="upJoin" runat="server">
                    <ContentTemplate>
<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">
    </obout:Calendar>
    <strong>
        <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">
    </obout:Calendar>
    &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>
<div class="clear">
</div>
<asp:LinkButton runat="server" ID="lbRecentPosts" Text="Recent Posts" PostBackUrl="~/Default.aspx"
    Font-Underline="true"></asp:LinkButton>
<asp:GridView runat="server" ID="gvPostIts" AutoGenerateColumns="false" GridLines="None">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <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" />
                        </a>
                    </div>
                    <div id="PostIt_Right">
                        <div class="postIt_Title">
                            <h6>
                                <%# 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>
                                </span>
                        </div>
                        <div class="clear">
                        </div>
                        <div class="postIt_Comment">
                            <%# Eval("Comment") %>
                        </div>
                        <asp:Label ID="lblPostItId" runat="server" Text='<%# Eval("PostItId") %>' Visible="false" />
                    </div>
                    <div class="clear">
                    </div>
                    <asp:GridView runat="server" ID="gvComments" AutoGenerateColumns="false" GridLines="None"
                        OnRowDataBound="gvComments_RowDataBound">
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <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" />
                                        </a>
                                    </div>
                                    <div id="PostItComment_Right">
                                        <div class="postItComment_Title">
                                            <h6>
                                                <%# 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>
                                        <div class="clear">
                                        </div>
                                        <div class="postItComment_comment">
                                            <%#Eval("ShareItComment")%>
                                        </div>
                                        <asp:Label ID="lblPostItCommentId" runat="server" Text='<%# Eval("PostItCommentId") %>'
                                            Visible="false" />
                                    </div>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <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">
                                    <Buttons>
                                        <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" />
                                    </Buttons>
                                </obout:Editor>
                                <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"
                                        OnClick="lbCancelComment_Click"></asp:LinkButton>
                                    <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"
                                        OnClick="lbCommentLogin_Click"></asp:LinkButton>
                                </div>
                            </div>
                        </asp:Panel>
                        <div class="clear">
                        </div>
                        <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>
                            <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" />
                                </a>
                            </div>
                            <div class="postIt_ShareFB">
                                <a name="fb_share" type="icon" share_url='<%# "SharePostIt.aspx?PostItId=" & Eval("PostItId") %>'>
                                </a>

                                <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript">
                                </script>

                                </a>
                            </div>
                        </div>
                    </div>
                </div>
                </script>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
   </ContentTemplate>
                </asp:UpdatePanel>
ASKER CERTIFIED SOLUTION
Tasneem

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros