Question : How to build a dynamic form in a Sharepoint webpart?

Hi experts,

I'm developing a Sharepoint webpart which must show a form that the user will fill in.
The fields in the form are generated in the runtime dynamically. That means, that this webpart can be used by user1 and he configures it to show 3 fields, while another user2 can uses it to show a form with 5 fields, etc..

Well, I could render the fields of the form using C# code in the "Render" function of my Webaprt class which inherits from Microsoft.SharePoint.WebPartPages.WebPart class, and here is the code:

protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            writer.Write("First name: <input type=\"text\" name=\"fname\" />" +
                         "<br />Last name: <input type=\"text\" name=\"lname\" /><br />" +
                         "<input type=\"submit\" value=\"Submit\" />");
            writer.Write("<br/>");
        }

So, the actual webpart shows a form with two fields "Firstname" and "Lastname", and one button to submit.
First, is there a better method to reach my goal? If yes, how? If no, my problem,with this method, is : how can I associate the Click event handler to the button? So, when the user clicks on the button, How can I get the entered values in the the two fields?

Thanks.

Answer : How to build a dynamic form in a Sharepoint webpart?

What version of Windows are you running and what make/model is your laptop? What is the model/make of your DVD drive?

It sounds a bit like a defective drive, you could try to upgrade the DVD drives firmware, but likely that won't help, if you have another DVD-drive handy switching the two units would be a clear indicator as to whether or not I'm right about the drive being defective.
Random Solutions  
 
programming4us programming4us