ASP.NET Tutorial/Language Basics/Event — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:30, 26 мая 2010

Change img border stype in Input Button action (VB.net)

<%@ 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>
    <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="http://www.nfex.ru/style/logo.png" id="word_image" runat="server">
 </BODY>
 </HTML>


Get action sender text (VB.net)

<%@ Page Language="VB" %>
<script runat="server">
   Sub Button_Click(Sender As Object, e As EventArgs)
      Response.Write(Sender.Text)
   End Sub
</script>
<html>
<body>
   <form runat="server">
      <asp:button id="btSubmit" Text="Submit" runat=server OnClick="Button_Click"/>
   </form>
</body>
</html>


Report action trigger"s text (C#)

<%@ Page Language="C#" %>
<script runat="server">
   void Button1_Click(Object Sender, EventArgs e) {
      Label1.Text = "You clicked <b>" + ((Button)Sender).Text + "</b>";
   }
</script>
<html><body>
   <form runat="server">
      <asp:Button id=Button1 runat="server" Text="Button1"
         onClick="Button1_Click" />
         
         <asp:Label id=Label1 runat=server />
   </form>
</body></html>


Report action trigger"s text (VB)

<%@ Page Language="VB" %>
<script runat="server">
   Sub Button1_Click(Sender as Object, e as EventArgs)
      Label1.Text="You clicked <b>" & Sender.Text & "</b>"
   end Sub
</script>
<html><body>
   <form runat="server">
      <asp:Button id=Button1 runat="server" Text="Button1"
         onClick="Button1_Click" />
         
         <asp:Label id=Label1 runat=server />
   </form>
</body></html>