View Single Post
  #2 (permalink)  
Old August 20th, 2010, 11:44 AM
chroniclemaster1 chroniclemaster1 is offline
Friend of Wrox
Points: 1,749, Level: 16
Points: 1,749, Level: 16 Points: 1,749, Level: 16 Points: 1,749, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: San Diego, CA, USA.
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

Quote:
Originally Posted by Gayathri79 View Post
btn.Text = "submit";
btn.CausesValidation = true;
btn.Click += new EventHandler(btn_Click);//not firing
Form.Controls.Add(btn);
Form.Controls.Add(new LiteralControl("<br>"));
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.
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.