How to delete a button control?

Posted on 2007-10-09
Last Modified: 2010-04-15
I have following code:

 private void BuildPostSurveyQuestionTable(int ID)
// I create a new  table here each time whenever I call this BuildPostSurveyQuestionTable

               HtmlTableCell cellCommand;
               HtmlTableRow rowCommand;
               ValidationSummary valsum = new ValidationSummary();
               valsum.ValidationGroup = "submit";
               valsum.ShowMessageBox = false;
               valsum.ShowSummary = false;
               cellCommand = new HtmlTableCell();
               cellCommand.ColSpan = 3;
               cellCommand.Align = "right";
               Label lblSubmitStatusPost = new Label();
               lblSubmitStatusPost.ID = "lblSubmitStatusPost";
               Button btnSubmitPost = new Button();
               btnSubmitPost.Text = "Save";
               btnSubmitPost.CommandArgument = ID.ToString();
               btnSubmitPost.Click += new EventHandler(btnSubmitPost_Click);
               btnSubmitPost.ValidationGroup = "submit";
               rowCommand = new HtmlTableRow();

I have to call this code multiple times. But its works fine the first time only, when I call it second time it doesn't jump on btnSubmitPost_Click(),  after clicking the button it should jump to btnSubmitPost_Click()  every time but why it only works for first survey only and not  for the second one? Do I need to destroy btnSubmitPost control everytime? how do i do this?

how do I create a control with the same name again?  how do I destroy the previous one?


Question by:waqarali1999
    LVL 7

    Accepted Solution

    Can u place the code that you call this sub from ,, it should work in every call ,, why u have to destroy the controls?

    Author Comment

    I need to pass different  CommandArgument  everytime.  btnSubmitPost.CommandArgument = ID.ToString();

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now