Note that there are some explanatory texts on larger screens.

plurals
  1. PORefreshing a Repeater control in an UpdatePanel with ASP.NET
    primarykey
    data
    text
    <p>I'm trying to code a page where you can post a comment without reloading the whole page. The comments are displayed using a Repeater control. The template looks like this:</p> <pre><code> &lt;asp:UpdatePanel runat="server" ID="commentsUpdatePanel" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;!-- Comments block --&gt; &lt;div class="wrapper bloc content"&gt; &lt;h3&gt;&lt;img src="img/comments.png" alt="Comments" /&gt;&amp;nbsp;Comments&lt;/h3&gt; &lt;p&gt;&lt;asp:Label ID="viewImageNoComments" runat="server" /&gt;&lt;/p&gt; &lt;asp:Repeater ID="viewImageCommentsRepeater" runat="server"&gt; &lt;HeaderTemplate&gt; &lt;div class="float_box marge wrapper comments"&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;div class="grid_25"&gt; &lt;span class="user"&gt;&lt;%#Eval("username")%&gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="font-size:x-small; color:#666"&gt;&lt;%#Eval("datetime") %&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="grid_75"&gt; &lt;p align="justify"&gt;&lt;%#Eval("com_text") %&gt;&lt;/p&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;FooterTemplate&gt; &lt;/div&gt; &lt;/FooterTemplate&gt; &lt;/asp:Repeater&gt; &lt;/div&gt; &lt;!-- Post comment block --&gt; &lt;div class="wrapper bloc content"&gt; &lt;h3&gt;&lt;a id="post_comment" name="post_comment"&gt;&lt;img src="img/comment_edit.png" alt="Comments" /&gt;&lt;/a&gt;&amp;nbsp;Post a comment&lt;/h3&gt; &lt;p class="description"&gt;Please be polite.&lt;/p&gt; &lt;p&gt; &lt;asp:Label ID="postCommentFeedback" runat="server" /&gt; &lt;/p&gt; &lt;table border="0"&gt; &lt;tr&gt; &lt;td valign="top"&gt; &lt;asp:TextBox id="postCommentContent" runat="server" TextMode="MultiLine" MaxLength="600" Columns="50" Rows="15" Width="400px" /&gt; &lt;/td&gt; &lt;td valign="top"&gt; &lt;span style="font-size:x-small"&gt;BBCode is enabled. Usage :&lt;br /&gt; &lt;b&gt;bold&lt;/b&gt; : [b]bold[/b]&lt;br /&gt; &lt;i&gt;italic&lt;/i&gt; : [i]italic[/i]&lt;br /&gt; &lt;span class="style1"&gt;underline&lt;/span&gt; : [u]underline[/u]&lt;br /&gt; Link : [url=http://...]Link name[/url]&lt;br /&gt; Quote : [quote=username]blah blah blah[/quote]&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;asp:Button ID="postCommentButton" runat="server" Text="Submit" onclick="postCommentButton_Click" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>The postCommentButton_Click() function works just fine - clicking "Submit" will make the post. However, I need to completely reload the page in order to see new comments - the post the user just made will not show until then. I Databind the Repeater in Page_Load() after a (!isPostBack) check.</p> <p>The postCommentButton_Click() function looks like this:</p> <pre><code>protected void postCommentButton_Click(object sender, EventArgs e) { // We check if user is authenticated if (User.Identity.IsAuthenticated) { // Attempt to run query if (Wb.Posts.DoPost(postCommentContent.Text, Request.QueryString["imageid"].ToString(), User.Identity.Name, Request.UserHostAddress)) { postCommentFeedback.Text = "Your post was sucessful."; postCommentContent.Text = ""; } else { postCommentFeedback.Text = "There was a problem with your post.&lt;br /&gt;"; } } // CAPTCHA handling if user is not authenticated else { // CAPTCHA } } </code></pre> <p>In my case, we do see postCommentFeedback.Text refreshed, but, again, not the content of the repeater which should have one more post.</p> <p>What is it I'm missing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload