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.
Printable View
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.
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>
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,
Erm not all controls will post back. Any kind of button will, image, hyperlin or normal. A dropdownlist will if you specify autopostback=true.