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)
writer.Write("First name: <input type=\"text\" name=\"fname\" />" +
"<br />Last name: <input type=\"text\" name=\"lname\" /><br />" +
"<input type=\"submit\" value=\"Submit\" />");
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?