Reputation: 107
I had something very strange problem I added the Ajax updatepanel when firing button event to prevent the whole page from loading . I added the button event well but when I run debugger to chek the code processes the textbox return empty although I added the text . when I> tried to move the text box out the updatepanel the found that the button event cannot find the textbox control . so what the problem ?
<asp:DataList ID="DL_userpost" runat="server" CssClass="single-posts" RepeatColumns="1"
OnItemCommand="DL_userpost_ItemCommand">
<ItemTemplate>
<div class="single-posts">
<div class="post-user">
<a href="#"></a>
</div>
<div class="post-container-all">
<div class="post-user-single-img">
<asp:Image ID="Img_Twasol" runat="server" ImageUrl='<%# Eval("Post_File")%>' Width="130"
Height="99" /></div>
<div class="post-user-single-data-tabs">
<div class="post-user-single-data-title">
<%#Eval("User_Name")%>
</div>
<div class="post-user-single-data-text">
<%#Eval("Post_Content")%>
</div>
</div>
</div>
<div class="comment">
<asp:UpdatePanel ID="UPPublicComment" runat="server" >
<ContentTemplate>
<asp:Panel ID="pnpublicpost" runat="server" DefaultButton="Btn_publicpost">
<asp:TextBox runat="server" ID="txt_publicpost" CssClass="comment-tabs2"></asp:TextBox>
<asp:ImageButton ID="Btn_publicpost" CommandName="publicpost" ValidationGroup="publicpost"
runat="server" OnClick="Btn_publicpost_Click" Style="display: none" />
<asp:Label ID="LblpublicpostPID" runat="server" Text='<%#Eval("Post_ID")%>' Visible="false"></asp:Label>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:DataList>
Upvotes: 0
Views: 184
Reputation: 3088
I copied exactly your code from above to the Markup and made this method in the Code behind... your code looks fine
Upvotes: 1
Reputation: 27
Add UpdateMode="Conditional"
in the UpdatePanel
.
<asp:UpdatePanel runat="server" ID="UpdInfo" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TxtInfo" runat="server />
</ContentTemplate>
</asp:UpdatePanel>
Upvotes: 0