CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2006
    Posts
    7

    Pick a button - any button

    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

  2. #2

    Re: Pick a button - any button

    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.

  3. #3
    Join Date
    Oct 2006
    Posts
    7

    Re: Pick a button - any button

    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

  4. #4
    Join Date
    Jul 2001
    Location
    Otaki, New Zealand
    Posts
    303

    Re: Pick a button - any button

    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

    otherwise a Google search turns up lots of interesting TreeView Control code and articles.

    Regards
    Alan

  5. #5
    Join Date
    Oct 2006
    Posts
    7

    Re: Pick a button - any button

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured