I was trying to create "asp:buttons" dynamically with special asp tags (<%%>) as I am using a loop in the codebehind to generate x amount of buttons based on the database. However, when the special tag tries to write out the asp button, the button does not work.
I know that the problem is due to it not converting when it's being written out.
For example, when I view source an asp button is suppose to look like this:
<input type="submit" name="ctl00$ContentPlaceHolder1$Button1" value="Hello" id="ContentPlaceHolder1_Button1" class="button" style="color:White;background-color:Transparent;border-style:None;" />
but the asp button being written on the view source was shown as:
<asp:Button ID='Button1' CssClass='button' BackColor='Transparent' runat='server' BorderStyle='None' ForeColor='white' Text='Hello' OnCommand='Button1_Click' CommandArgument='cat0002' />
If there are other ways to create the buttons please do recommend me too as I have to create them dynamically while trying to display them in the individual table data I created. And I would need to pass the values through to the code behind as I have to call the SQL database when its clicked.
Buttonconstructor likenew Button() { ID = "buttonID", Text = "ButtonText" }and then putbutton.Click += (sender, e) { // click event here }. Don't forget to add button control into the form afterwards withFormName.Controls.Add.