Click to See Complete Forum and Search --> : Pick a button - any button
curtis.dehaven
October 14th, 2006, 06:03 PM
I have a page that has a Table control - I tried DataGrid, but Table lets me use different sized cells and columns per row which I need. I'm building the table on the fly in code. I need to put a link and/or button on some cells and use that for a post-back. So far, I've put html for a button right in the "Text" property of those cells. With them being of type "submit" I am getting a post-back - that is I'm getting into my Page_Load.
But how do I get into an event handler or better yet, how do I know which button was pressed? What's gonna happen next is depending on which button was hit, we'll hit the database and send back an updated table.
Thanks for any help!
Curt
mmetzger
October 14th, 2006, 10:39 PM
It's a little hard to explain how this works...
Basically, you need to create a server control (either asp:button or <input type=button runat="server">) and reference it accordingly. For each button, assign a handler for the onClick event - you can then check the attributes and perform whatever operation you need.
curtis.dehaven
October 15th, 2006, 09:58 PM
mm, thanks for the reply and the help. I continue to learn more and more about this thing called asp.net...
Recall I'm putting client-side html into a "Table" server control. You suggested a server control such as asp:button or even input. I thought of that too but the problem is that whatever html I put into the TableCell's text property, it's only seen by the client - the server never even gets to see it. So what's the client to do with a "runat"...
I ended up assigning an onclick to the button and then using js to write to an asp.net text control with the button id. From there, I rely on the viewestate to get the button id to the server... I dont really like that but it works.
I'm trying to port a classic-asp asp-html tree-control into asp.net. If ya got any other suggestions for a tree control, please share. Thanks again.
Curt
AlanGRutter
October 15th, 2006, 10:47 PM
Sounds like something very common that someone else has probably already done.
If you're using ASP.NET 2.0 have you looked at the TreeView control
TreeView Control Article (http://www.15seconds.com/issue/041117.htm)
otherwise a Google search turns up lots of interesting TreeView Control code and articles.
Regards
Alan
curtis.dehaven
October 17th, 2006, 07:07 AM
Alan
Thanks for the tip! I just install Dev Studio 2005 and checked out MSoft's tree control. Actually I spent more time installing the software than I did getting the control to work with my database - it came right up...
Thanks again!
Curt
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.