The Problem is when i click OnClick event of lnkbtnLike the property lnkbtnLike.visible = false is not working. i debug the code and check its value , it successfully takes the value false but when page loads after click event lnkbtnLike is still visible to true. I can't understand why this is happening?
I am also using a repeater control on that page but these link buttons are out of reapeater body . I Think may be because of repeater control lnkbtnLike visible property is not working.. Please let me clear this. Thank you !
What I have tried:
<div class="row">
<div class="col-sm-12">
class="fa fa-thumbs-o-up" id="lblLike">
<asp:LinkButton ID="lnkBtnLike" runat="server" Style="color: darkgray" OnClick="lnkBtnLike_Click">Likes</asp:LinkButton>
<asp:LinkButton ID="lnkBtnUnlike" runat="server" OnClick="lnkBtnUnlike_Click" Visible="false">Liked</asp:LinkButton>
^__i class="fa fa-comments">
<asp:Label ID="lblComment" runat="server"></asp:Label>
</div>
</div>
<asp:Panel ID="Panel1" runat="server">
<div class="row">
<asp:Repeater ID="rptComment" runat="server">
<ItemTemplate>
<!-- main-comment-container -->
<div class="comments-container">
<ul class="comments-list">
<li>
<div class="comment-main-level">
<!-- Avatar -->
<div class="comment-avatar">
<img src="User/Attachments/userpro.jpg" alt="">
</div>
<!-- CommentBox -->
<div class="comment-box">
<div class="comment-head">
<h6 class="comment-name"><a href="#"><%#Eval("ProfileName") %></a></h6>
<span><%#Eval("CreatedDate") %></span>
</div>
<div class="comment-content">
<%# Eval("Comment") %>
</div>
</div>
</div>
<!-- Relpy-container -->
<%--<ul class="reply-list">
<li>
<div class="comment-main-level">
<!-- Avatar -->
<div class="comment-avatar">
<img src="User/Attachments/userpro.jpg" alt=""></div>
<!-- CommenBox -->
<div class="comment-box">
<div class="comment-head">
<h6 class="comment-name"><a href="">Biju Nakarmi</a></h6>
<span>have 7 minutes</span>
</div>
<div class="comment-content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit omnis animi et iure laudantium vitae, praesentium optio, sapiente distinctio illo?
</div>
</div>
</div>
<!-- Relpy-container -->
<ul class="reply-list">
<li>
<div class="comment-main-level">
<!-- Avatar -->
<div class="comment-avatar">
<img src="http://younginnovations.com.np/images/staffs/Rakesh.png" alt=""></div>
<!-- CommentBox -->
<div class="comment-box">
<div class="comment-head">
<h6 class="comment-name by-author"><a href="g">Rakesh Nunchen Pradhan</a></h6>
<span>have 2 minutes</span>
</div>
<div class="comment-content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit omnis animi et iure laudantium vitae, praesentium optio, sapiente distinctio illo?
</div>
</div>
</div>
</li>
<!-- Relpy-container -->
<ul class="reply-list">
<li>
<div class="comment-main-level">
<!-- Avatar -->
<div class="comment-avatar">
<img src="http://younginnovations.com.np/images/staffs/Biju.png" alt=""></div>
<!-- CommentBox -->
<div class="comment-box">
<div class="comment-head">
<h6 class="comment-name"><a href="">Biju Nakarmi</a></h6>
<span>have 10 minutes</span>
</div>
<div class="comment-content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit omnis animi et iure laudantium vitae, praesentium optio, sapiente distinctio illo?
</div>
</div>
</div>
<!-- Relpy-container -->
<ul class="reply-list">
<li>
<div class="comment-main-level">
<!-- Avatar -->
<div class="comment-avatar">
<img src="http://younginnovations.com.np/images/staffs/Sweta.png" alt=""></div>
<!-- Comment-box -->
<div class="comment-box">
<div class="comment-head">
<h6 class="comment-name"><a href="">Sweta Shrestha</a></h6>
<span>have 30 minutes</span>
</div>
<div class="comment-content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit omnis animi et iure laudantium vitae, praesentium optio, sapiente distinctio illo?
</div>
</div>
</div>
</li>
</ul>
</li>
<li>
<div class="comment-main-level">
<!-- Avatar -->
<div class="comment-avatar">
<img src="http://younginnovations.com.np/images/staffs/Rakesh.png" alt=""></div>
<!-- CommentBox -->
<div class="comment-box">
<div class="comment-head">
<h6 class="comment-name by-author"><a href="">Rakesh Nunchen Pradhan</a></h6>
<span>have 10 minutes</span>
</div>
<div class="comment-content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit omnis animi et iure laudantium vitae, praesentium optio, sapiente distinctio illo?
</div>
</div>
</div>
</li>
</ul>
</ul>
</li>
</ul>--%>
</li>
</ul>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</asp:Panel>
protected void lnkBtnLike_Click(object sender, EventArgs e)
{
try
{
using(database db = new database())
{
tblBlogLike tbl = new tblBlogLike();
tbl.UserId = (Int64.Parse(new StandardModule().Decrypt(HttpUtility.UrlDecode(Request.QueryString["uid"])).ToString()));
tbl.BlogId = (Int64.Parse(new StandardModule().Decrypt(HttpUtility.UrlDecode(Request.QueryString["bid"])).ToString()));
tbl.Like = (Int64.Parse(new StandardModule().Decrypt(HttpUtility.UrlDecode(Request.QueryString["uid"])).ToString()));
tbl.Status = "A";
tbl.Flag = "NA";
tbl.Remarks = "NA";
tbl.CreatedDate = DateTime.Now;
db.tblBlogLikes.Add(tbl);
db.SaveChanges();
db.Entry<tblBlogLike>(tbl).Reload();
lnkBtnLike.Visible= false;
lnkBtnUnlike.Visible= true;
Response.Redirect(Request.Url.AbsoluteUri, false);
}
}
catch(Exception ex)
{
Response.Redirect(ex.Message);
}
}