-1

I am tring to Create a Comment box having reply option for my Website

Below Is My aspx page

 <div>

                <asp:Repeater runat="server" ID="repAnswer">
                    <ItemTemplate>
                        <h6>Answer</h6>

                        <p><%# Eval("Answer") %></p>
                        <asp:Label runat="server" ID="lblAnsId" Text='<%# Eval("AnsId")%>' Visible="false"></asp:Label>

                        <a class="link" id='lnkReplyParent<%#Eval("AnsId") %>' href="javascript:void(0)" onclick="showReply(<%#Eval("AnsId") %>);return false;">Reply</a>   

                        <a class="link" id="lnkCancle" href="javascript:void(0)" onclick="closeReply(<%#Eval("AnsId") %>);return false;">Cancle</a>  

                          <div id='divReply<%#Eval("AnsId") %>' style="display:none;">  
                             <asp:TextBox ID="textCommentReplyParent" CssClass="input-group" runat="server" Width="300px" TextMode="MultiLine" ></asp:TextBox>  
                             <br />  
                             <asp:Button ID="btnReplyParent" runat="server" Text="Reply" OnClick="btnReply_Click" /></div>

                    </ItemTemplate>
                </asp:Repeater>

            </div>
             <div style="margin-top:100px">
                 <h5>Your Answer</h5>
                 <hr />
                <CKEditor:CKEditorControl ID="txtAddAnswer" BasePath="Admin/ckeditor/" runat="server">
             </CKEditor:CKEditorControl>
                 <asp:Button runat="server" ID="btnAnswer" Text="Submit Answer" OnClick="btnAnswer_Click"/>
            </div>

i have used Repeater to bind my answer or comment. Inside the repeater i have given two link pne is of reply other is of cancel.when someone click on the reply a new textbox and button open which is used to give the reply

Below is my cs page

 protected void btnReply_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem row in repAnswer.Items)
        {
            Label lblNewAnsIdholder = (Label)row.FindControl("lblNewAnsIdholder");
            TextBox txtReplyToAnswer = (TextBox)row.FindControl("txtReplyToAnswer");

            OnlineSubjects onlinesub = new OnlineSubjects()
            {
                reply = txtReplyToAnswer.Text.Trim(),
                AnsId = Convert.ToInt32(lblNewAnsIdholder.Text.ToString())
            };
            onlinesub.addAnswer();
        }          
    } 

i dont know how to use textbox in repeater but after searching it through google i get something like this which i am not sure thats right or wrong. And the line where i have created my object for my class i am getting error from there I am tring to pass the value of textbox as a paramter Plz help me to do this. Thank You

2

1 Answer 1

0

You Should try,

TextBox txtReplyToAnswer = ((TextBox)row.FindControl("txtReplyToAnswer")).Text;

Hope this will work.

Sign up to request clarification or add additional context in comments.

1 Comment

What I am seeing in your code is you are referring wrong Textbox id in the repeater. Ideally, it should be as per your code "textCommentReplyParent" but you are referring "txtReplyToAnswer".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.