Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a code in which- on clicking on "Comment" button creates a ("multiline textbox",and two buttons- "Submit" & "Cancel"). These controls are added to panel "PLComment". On clicking on Cancel button the panel should hide and "Comment" button should be displayed without page refresh. I have used AJAX also. Below is the code.
---------------------------------------------------------------------------------
ASPX:
----------------------------------------------------------------------------------
ASP.NET
<div id="AnsCommentBox" class="question-answered question-answered-done">
                                        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                                        <asp:UpdatePanel ID="UpdatePanelComment" runat="server">
                                            <ContentTemplate>
                                                   <asp:Button ID="btnComment" runat="server" Text="Have a Comment?" CssClass="button btn btn-small" OnClick="PostComment" />
                                                <asp:Panel ID="PlComment" runat="server" ></asp:Panel>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                       <%-- <i class="icon-comments"></i>--%>
                                     
									</div>


----------------------------------------------------------------------------------
C# code:
----------------------------------------------------------------------------------
C#
protected void PostComment(object sender,EventArgs e)
     {
         TextBox txtAnswerComment = new TextBox();
         Button btnSubmit = new Button();
         Button btnCancel = new Button();
         btnSubmit.Text = "Submit";
         btnCancel.Text = "Cancel";
         btnCancel.Style.Add("font-size", "12px;");
         btnCancel.Style.Add("Padding", "4px 10px;");
         btnCancel.Style.Add("font-size", "12px;");
         btnSubmit.Style.Add("Padding", "4px 10px;");

         btnSubmit.Attributes.Add("class", "button small blue-button");
         btnSubmit.Attributes.Add("runat", "server");
         btnSubmit.Style.Add("font-size", "12px");
         btnCancel.Attributes.Add("class", "button small red-button");
         btnCancel.Attributes.Add("runat", "server");

         txtAnswerComment.ID = "txtAnswerComment";
         txtAnswerComment.TextMode = TextBoxMode.MultiLine;
         txtAnswerComment.Style.Add("Width","700px;");
         txtAnswerComment.Style.Add("Height", "80px;");
         txtAnswerComment.Attributes.Add("runat", "server");
         txtAnswerComment.Font.Size = 9;
         txtAnswerComment.Style.Add("resize", "none;");
         PlComment.Controls.Add(txtAnswerComment);
         PlComment.Controls.Add(btnSubmit);
         PlComment.Controls.Add(btnCancel);
         btnComment.Visible = false;
        btnCancel.Click += btnCancel_Click;

     }

    protected void btnCancel_Click(object sender,EventArgs e)
        {
            
            PlComment.Visible = false;
            btnComment.Visible = true;
        }


What I have tried:

I have tried using AJAX but the "Comment" button shows after refreshing the page manually.
Posted
Updated 13-Apr-16 0:34am

1 solution

First make a dummy html having comment controls then onclick button you need to append the html and show it via jquery.
 
Share this answer
 

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