ASP HTML Code

    <asp:Panel ID="pnlQuestions" runat="server" Width="100%">
    </asp:Panel>
    <asp:LinkButton ID="lbtnNext" runat="server" CssClass="button" ToolTip="Next"
    OnClick="lbtnNext_Click"><span>Save & Next</span></asp:LinkButton>

aspx.cs

    protected void Page_Init(object sender, EventArgs e)
    {
         TextBox txt = new  TextBox();
         txt.Text = QuestionText;
         txt.ID = "que1";
         pnlQuestions.Controls.Add(txt);
    }

Обработка динамического контрола

     protected void lbtnNext_Click(object sender,EventArgs e)
     {
          TextBox txt = ((TextBox)pnlQuestions.FindControl("que1"));
          AnswerText = txt.Text.Trim();
          Response.Write(AnswerText); 
     }
Enter your comment. Wiki syntax is allowed:
 
  • ms_windows_ms_sql/dynamicaly_created_controls_in_asp_pages.txt
  • Last modified: 2019/02/11 09:13
  • by 127.0.0.1