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:
----------------------------------------------------------------------------------
<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>
<%----%>
</div>
----------------------------------------------------------------------------------
C# code:
----------------------------------------------------------------------------------
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.