Friday, June 24, 2011

Manipulating HTML Server Controls

    <%@ Page Language="VB" %>

    <script runat="server">
       Sub Click(Sender as Object, e as EventArgs)
          select case Sender.Value
             case "Left"
                word_image.align = "left"
             case "Right"
                word_image.align = "right"
             case "Center"
                word_image.align = "center"
          end select

          Left.Style("Border-Style") = "notset"
          Right.Style("Border-Style") = "notset"
          Center.Style("Border-Style") = "notset"

          Sender.Style("Border-Style") = "inset"
        end Sub
    </script>

    <html><body>
        <font size="5">Sam's Teach Yourself ASP.NET in
        21 Days: Day 5 </font><hr><p>

        <form runat="server">
           <input type="Button" id="Left" runat="server"
              Value="Left" OnServerClick="Click" />
           <input type="Button" id="Center" runat="server"
              Value="Center" OnServerClick="Click" />
           <input type="Button" id="Right" runat="server"
              Value="Right" OnServerClick="Click" />
        </form>

        <img src="word.gif" id="word_image" runat="server">
        <div id="Label1" runat="server">This is an example
        of text. When the buttons above are clicked, the image
        will move around the text accordingly.<p> This example
        demonstrates the HtmlImage and HtmlInputButton controls.
        </div>

   </body></html>

No comments:

Post a Comment