Results 1 to 4 of 4

Thread: Submitting a form in ASP .NET

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    94

    Red face Submitting a form in ASP .NET

    How in the name of all your gods do you submit a form in ASP .NET using a submit button?

    Any help would be very much appreciated!

    Gulliver.

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    Code:
    <script language="vb" runat="server">
    Sub mySubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    	If Page.IsPostBack Then 'prove you're really posting the form.
    		myLabel.Text = "Thanks for posting that form!"
    	End If
    End Sub
    </script>
    <html>
    	<head>
    		<title>Post Test</title>
    	</head>
    	<body>
    		<form id="submitTest" runat="server">
    			<asp:Label
    				ID="myLabel"
    				Runat="server"/>&nbsp;<br/>	
    			<asp:Button
    				ID="mySubmitButton"
    				Runat="server"
    				OnClick="mySubmitButton_Click"
    				Text="Click Me!"/>
    		</form>
    	</body>
    </html>

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Just a little background on this...

    If you use any controls that utilize runat="server" then any interaction that occurs with those controls will do a postback to the server. Then as mentioned above, in your PageLoad code you can check the postback, as well as validate that all information was entered properly.

    Hope this makes sense,

  4. #4
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    Erm not all controls will post back. Any kind of button will, image, hyperlin or normal. A dropdownlist will if you specify autopostback=true.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width