USAGE OF REQUEST AND RESPONSE OBJECT-(TYPE-II)



DEFAULT.ASPX FILE:


%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
    </div>
    <asp:Label ID="Label1" runat="server" Text="Enter Your name:"></asp:Label>
    <asp:TextBox ID="myfield" runat="server" Height="22px"></asp:TextBox><br />
    <asp:Button ID="Button1" runat="server" Text="click me" Width="159px" />
    </form>
</body>
</html>

DEFAULT.ASPX.VB FILE:

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mystring As String = Request.Form("myfield")
        If mystring = "" Then
            Response.Write("Please fill in the form field")
        Else
            Response.Write("thank you [" & (mystring) & "]<br/>")
        End If
    End Sub
 End Class

No comments:

Post a Comment