CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2010
    Posts
    1

    Question Combining textboxes to a buttons

    Okey, so heres the deal, we just started on C#, as you might understand I'm a newbie!

    I got a input field, four buttons and four outputfields. When I type something in the input field and click button 3 the text is gonna come in outputfield 3. same goes for every other button.

    Tekst<asp:TextBox ID="txtbInput" runat="server"></asp:TextBox>
    <br />
    <asp:Button ID="btnKnapp1" runat="server" Text="Knapp1" OnClick="Button1" />
    <asp:Button ID="btnKnapp2" runat="server" Text="Knapp2" OnClick="Button1" />
    <asp:Button ID="btnKnapp3" runat="server" Text="Knapp3" OnClick="Button1" />
    <asp:Button ID="btnKnapp4" runat="server" Text="Knapp4" OnClick="Button1" />
    <br />
    En<asp:TextBox ID="txtbUtskrift1" runat="server"></asp:TextBox><br />
    To<asp:TextBox ID="txtbUtskrift2" runat="server"></asp:TextBox><br />
    Tre<asp:TextBox ID="txtbUtskrift3" runat="server"></asp:TextBox><br />
    Fire<asp:TextBox ID="txtbUtskrift4" runat="server"></asp:TextBox>

    protected void Button1(object sender, EventArgs e)
    {
    Button button = (Button)sender;
    txtbInput.Text = button.ID;
    }

    so what this do for me is input the ID of each button into the input field. So I've looked into Switch case, but I cant figure out how to do this! I dont want you guys to simply do the task for me, but give me heads up and point me in the right direction!

    Thanks in advance!

  2. #2
    Join Date
    Sep 2010
    Posts
    1

    Re: Combining textboxes to a buttons

    Hi

    Try this

    switch (button.ID) {
    case "btnKnapp1":
    // do some action
    break;
    }


    Hope this helps. Please let me know if you have got the answer or you think this is not what you are looking for

Tags for this Thread

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