Handle form submit (VB.net) : Submit Button « Asp Control « ASP.Net






Handle form submit (VB.net)

<%@ Page Language=VB Debug=true %>

<script runat=server>

Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    If Not IsPostBack Then
        Profession.Items.Add("Management")
        Profession.SelectedIndex = 2
        chkBreakfast.Checked= True
        radChicken.Checked = True
    End If
End Sub

Sub SubmitBtn1_Click(Source As Object, E as EventArgs)
    MyMessage.InnerHTML = "Hello " & UserName.Value _
        & ". Your password is " & Password.Value
End Sub

Sub SubmitBtn2_Click(Source As Object, E as ImageClickEventArgs)
    If radBeef.Checked = True Then
        MyMessage.InnerHTML = "So you want to eat beef?"
    Else
        MyMessage.InnerHTML = "So you want to eat chicken?"
    End If        
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Form Sample Page</TITLE>
</HEAD>
<BODY>
<form id="MyForm" Method="Post" runat="server">
  <Span id="MyMessage" runat=server>
  </Span>    
  <BR>    
  Name: 
  <BR>
  <Input id="UserName" runat="server" Type="text" MaxLength="50" Size="20" Value="Your Name">
  <BR>
  Password: 
  <BR>
  <Input id="Password" runat="server" Type="Password" MaxLength="50" Size="20"
  <BR>
  Address:<BR>
  <TextArea id="Address" runat="server" Cols="20" Rows="4">
Enter address here
</TextArea>
<BR>
Profession
<BR>
<Select
    id="Profession"
    runat="server"
    size=2
>
    <Option>Computers</Option>
    <Option>HR</Option>
</Select>
<BR>
Breakfast? 
<Input
    id="chkBreakfast"
    runat="server"
    type="checkbox"
>Lunch? 
<Input
    id="chkLunch"
    runat="server"
    type="checkbox"
    checked
>
Dinner? 
<Input
    id="chkDinner"
    runat="server"
    type="checkbox"
>
<BR>
Beef?
<Input
    id="radBeef"
    runat="server"
    type="radio"
    name="Meal"
>
Chicken?
<Input
    id="radChicken"
    runat="server"
    type="radio"
    name="Meal"
>
<BR><BR>
<input 
    runat="server"
    type="submit" 
    value="Submit Form" 
    OnServerClick="SubmitBtn1_Click" 
>
<input 
    runat="server"
    type="image"
    src="http://www.java2s.com/style/logo.png" 
    OnServerClick="SubmitBtn2_Click" 
>
</Form>
</BODY>
</HTML>
           
       








Related examples in the same category

1.ComboBox with Submit button (C#)