Question of submit form

gycx

New member
Joined
Dec 28, 2012
Messages
2
Programming Experience
Beginner
My english is no-good
<form action="About.aspx" method="post">
Name:<input id="Text1" type="text" name="name"/>
<br />
Password:<input id="Password1" type="password" name="password"/><br />
<input id="Submit1" type="submit" value="submit"/>
</form>
I can submit this form to About.aspx
I what to know how to submit form to About.aspx.vb or other .vb files
please help me,thank you
 
You need to add an asp:Button to your form and handle the Click event in your code behind. Also using asp:TextBox's instead of inputs would allow you to get the values in the server side code too. Here's an example:
HTML:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._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>About Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Name: <asp:TextBox ID="NameTextBox" runat="server" />
        <br />
        Password: <asp:TextBox ID="PasswordTextBox" TextMode="Password" runat="server" />
        <br /><br />
        <asp:Button ID="SubmitButton" Text="Submit" runat="server" />
    </div>
    </form>
</body>
</html>
And the code-behind file for that page:
Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            'Code for when the page is not a post back, as in this is the first time the page is being loaded.
        End If

        'Code for every time the page is sent to the webserver
        PasswordTextBox.Text = String.Empty 'Clear the password textbox on the page in case they had typed something in
    End Sub

    Private Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
        'Code for when the user clicks the submit button, this runs on the webserver not in the user's browser

        'Get the values typed in from the TextBox's on the page
        Dim UName As String = NameTextBox.Text
        Dim PW As String = PasswordTextBox.Text
    End Sub

End Class
 
my english is no-good
Thank you for your answer
I have solved this problem
this is my method:
in index.aspx

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<form action="../HelloWorld/Welcome" method="post">
Name:<input id="Text1" type="text" name="name" />
<br />
Password:<input id="Password1" type="password" name="password"/><br />
<input id="Submit1" type="submit" value="submit" />
</form>
</asp:Content>

in HelloWorldController.vb

Function Welcome(ByVal name As String, ByVal password As String) As String
Return "姓名:" & name & "<br>" & "密码:" & password
End Function
 
Back
Top