|
-
Nov 22nd, 2002, 09:54 AM
#1
Thread Starter
Lively Member
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.
-
Nov 22nd, 2002, 02:09 PM
#2
Hyperactive Member
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"/> <br/>
<asp:Button
ID="mySubmitButton"
Runat="server"
OnClick="mySubmitButton_Click"
Text="Click Me!"/>
</form>
</body>
</html>
-
Nov 22nd, 2002, 11:22 PM
#3
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,
-
Nov 24th, 2002, 07:53 PM
#4
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|