?
Solved

Postback causes Javascipted button to disappear

Posted on 2010-11-08
2
Medium Priority
?
1,021 Views
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: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>

Open in new window

0
Comment
Question by:gogetsome
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

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

Author Comment

by:gogetsome
ID: 34113747
mmm

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
            GetToday()
            lbLogin.Visible = False
            GetPostItFromSession()
            GetPostItForThreeDays()
        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


0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

752 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