Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
I have one table inside update panel, in which i show some data from database, some image buttons and some sharing icons(spam link removed). When my page loads it shows all information, buttons and share icons but as i click on botton the share icons hides. When i refresh page then its again shows. Why it is hiding when button click.
ASP.NET
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td colspan="5">
<asp:ImageButton ID="btn_like" runat="server" ToolTip="Like" onclick="btn_like_Click1" OnClientClick="Show('shareicons');" />
<asp:ImageButton ID="btn_favorite" runat="server" ToolTip="Favorite" onclick="btn_favorite_Click1"/>
<asp:ImageButton ID="btn_spam" runat="server" ToolTip="Spam" onclick="btn_spam_Click1"/>                            
</td>
</tr>
                    
<tr>
<td colspan="5">
<span class='st_facebook_large' displayText='Facebook' title="Share this Ad on Facebook"></span>
<span class='st_googleplus_large' displayText='Google +' title="Share this Ad on Google+"></span>
<span class='st_twitter_large' displayText='Tweet' title="Share this Ad on Twitter"></span>
<span class='st_linkedin_large' displayText='LinkedIn' title="Share this Ad on LinkedIn"></span>
<span class='st_email_large' displayText='Email' title="Share this Ad on Email"></span>
<span class='st_sharethis_large' displayText='ShareThis' title="More Sharing Options"></span>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btn_like" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btn_favorite" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btn_spam" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

C#
protected void btn_like_Click1(object sender, ImageClickEventArgs e)
    {
        if (null == Session["advertise"] || Session["advertise"] == null)
        {
            ScriptManager.RegisterStartupScript(this, typeof(string), "Error", "alert('Please login to Like this Advertisement.');", true);
        }
        else
        {
            ses = Session["advertise"].ToString();
            SqlCommand cmd = new SqlCommand("sps_checklike", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@ad_id", ad_id);
            cmd.Parameters.AddWithValue("@email", ses);
            cmd.Parameters.Add("@ERROR", SqlDbType.Int);
            cmd.Parameters["@ERROR"].Direction = ParameterDirection.Output;
            con.Open();
            cmd.ExecuteNonQuery();
            int s = (int)cmd.Parameters["@ERROR"].Value;
            con.Close();
            if (s == 1)
            {
                
                SqlCommand cmd3 = new SqlCommand("sps_decreaselike", con);
                cmd3.CommandType = CommandType.StoredProcedure;
                cmd3.Parameters.AddWithValue("@ad_id", ad_id);
                cmd3.Parameters.AddWithValue("@email", ses);
                con.Open();
                cmd3.ExecuteNonQuery();
                con.Close();
                btn_like.ImageUrl = "http://localhost:37698/Finder/Images/likeinactive.png";
                LoadDetails();
            }
            else
            {
                
                SqlCommand cmd2 = new SqlCommand("sps_increaselike", con);
                cmd2.CommandType = CommandType.StoredProcedure;
                cmd2.Parameters.AddWithValue("@ad_id", ad_id);
                cmd2.Parameters.AddWithValue("@email", ses);
                con.Open();
                cmd2.ExecuteNonQuery();
                con.Close();
                btn_like.ImageUrl = "http://localhost:37698/Finder/Images/likeactive.png";
                LoadDetails();
            }
        }
    }
Posted
Updated 2-Dec-14 6:37am
v4
Comments
Thanks7872 2-Dec-14 7:08am    
Beware of posting links like you did. It will be considered as spam.
Raj Negi 2-Dec-14 7:35am    
sorry for that...i just want to tell you from where i got the sharing icons.
Kornfeld Eliyahu Peter 2-Dec-14 7:17am    
Information is insufficient...Please improve your question...Add some code...So on...
Raj Negi 2-Dec-14 7:42am    
Its a very long table. I updated my question with two table rows where i facing problem.
TheRealSteveJudge 2-Dec-14 8:53am    
Which button did you click?
What is it's code behind?
...
Unfortunately my crystal ball is broken...

1 solution

Use refresh propery after any button event for UpdatePanel1
 
Share this answer
 
Comments
Raj Negi 3-Dec-14 2:18am    
how?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900