locked
how to raise event in vb asp.net 2.0 ? RRS feed

  • Question

  • User-1085086574 posted

    how to raise event in vb asp.net 2.0  ?

    Tuesday, September 14, 2010 2:56 AM

Answers

  • User1006193418 posted

    how to raise event in vb asp.net 2.0  ?

    Hi,

    Could you explain a bit more what you are after by asking how to raise event in VB.NET ASP.NET?

    The most simple test is to create a web application and add a button to the Default.aspx page and then, double click this button to write some code in the Button_Click event handler, so that when you run the page and click the button, you will raise the Button_Click event handler.

    For more detailed, you can follow these two ways to raise a event handler.

    1st way: using onclick attribute.

    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Response.Write("Hello World")
        End Sub
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        </div>
        </form>
    </body>
    </html>

    2nd way: using Handles key word after event handler.

    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Response.Write("Hello World")
        End Sub
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </div>
        </form>
    </body>
    </html>

    If I have misunderstood you, please feel free to let me know.

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 16, 2010 11:36 PM

All replies

  • User-1828494216 posted

    Siple search on web would give you all the answers.

    For a start take a look at this

    http://msdn.microsoft.com/en-us/library/edzehd2t%28VS.71%29.aspx

    http://msdn.microsoft.com/en-us/library/ms973905.aspx


    Tuesday, September 14, 2010 10:01 AM
  • User1006193418 posted

    how to raise event in vb asp.net 2.0  ?

    Hi,

    Could you explain a bit more what you are after by asking how to raise event in VB.NET ASP.NET?

    The most simple test is to create a web application and add a button to the Default.aspx page and then, double click this button to write some code in the Button_Click event handler, so that when you run the page and click the button, you will raise the Button_Click event handler.

    For more detailed, you can follow these two ways to raise a event handler.

    1st way: using onclick attribute.

    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Response.Write("Hello World")
        End Sub
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        </div>
        </form>
    </body>
    </html>

    2nd way: using Handles key word after event handler.

    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Response.Write("Hello World")
        End Sub
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </div>
        </form>
    </body>
    </html>

    If I have misunderstood you, please feel free to let me know.

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 16, 2010 11:36 PM