Originally Posted by Gayathri79
btn.Text = "submit";
btn.CausesValidation = true;
btn.Click += new EventHandler(btn_Click);//not firing
I have an idea you can check. In C# the default for AutoEventWireup is true. Check the @Page directive at the top of your file to be sure (though I've never been able to program with it set to false).
That means that you simply declare function name and .NET takes care of the relevant wiring for you. Since you then add the event manually here, this might be the only problem. If I'm right, then try commenting out this one line and then see if it works.
Also, it's nice to see someone (besides me) working programmatically, I find it much more powerful. You may already know this, but you may find the <asp:Literal /> control of interest as well. The Label control wraps the Text you specify in a <span> tag, while the literal control outputs it as is. That means you can specify any XHTML out want in addition to the text, which is a level of flexibility that you can use to do some fairly major custom design.