C# Button Value

I can't grab Button Value in C#. Server message .Web.UI.WebControls.Button' does not contain a definition for 'value'.
In VB I don't get this message.
void Click(object Sender, EventArgs e)
        Button btRes;
        btRes = (Button)Sender;
       switch (btRes.value)
            case "Left":
                contact.Align = "left";
            case "Right":
                contact.Align = "right";
            case "Center":
                contact.Align = "center";
<form runat="server">
    <input type="Button" id="Left" runat="server" value="Left" onserverclick="Click" style="width: 71px; height: 27px" />
    <input type="Button" id="Right" runat="server" value="Right" onserverclick="Click" />
    <input type="Button" id="Center" runat="server" value="Center" onserverclick="Click" />

Open in new window

Who is Participating?
David H.H.LeeConnect With a Mentor Commented:
Hi htinawi,
You need to call "HtmlInputButton" instead of default web button inside the function.
These lines:
        Button btRes;
        btRes = (Button)Sender;
Change to
        System.Web.UI.HtmlControls.HtmlInputButton btRes;
        btRes = (System.Web.UI.HtmlControls.HtmlInputButton)Sender;
htinawiAuthor Commented:
I tried the above. I get effectively the same message.

Compiler Error Message: CS0117: 'System.Web.UI.HtmlControls.HtmlInputButton' does not contain a definition for 'value'

Source Error:

Line 8:          System.Web.UI.HtmlControls.HtmlInputButton btRes;
Line 9:          btRes = (System.Web.UI.HtmlControls.HtmlInputButton)Sender;
Line 10:        switch (btRes.value)
Line 11:         {
Line 12:             case "Left":
philipjonathanConnect With a Mentor Commented:
It should be 'Value' with capital V. Please give credit to x_com, I'm just helping
htinawiAuthor Commented:
I'm just learning C#.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.