Buttons Part 1 and Buttons Part 2
Summary
Buttons Part 1 – This video shows how to use buttons and the event capture sequences associated with buttons when using the click event and the PostBackUrl. Demonstrates troubleshooting techniques for using button behavior.
Buttons Part 2 -This video continues to demonstrate the event capture model, shows how to pass values from a PostBack and also the UseSubmitBehavior property. Demonstrates differences between PostBack and hyperlinking.
Video
Buttons Part 1 – http://online1.daytonastate.edu/player2.php?id=b4baaff0e2f11b5356193849021d641f
Buttons Part 2 – http://online1.daytonastate.edu/player2.php?id=ea4eb49329550caaa1d2044105223721
Reference Materials
Button1.aspx
<body>
<form id="form1" runat="server">
<div>
Enter Something <asp:TextBox ID="tb" runat="server"></asp:TextBox><br /><br />
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/FormObjectExamples/Button2.aspx">Go To Next Form</asp:HyperLink>
<br /><br />
<asp:Button ID="Button1" runat="server"
Text="Go To Next Form"
PostBackUrl="~/FormObjectExamples/Button2.aspx" />
<asp:Button ID="Button2" runat="server"
onclick="Button2_Click"
Text="Go To Default"
UseSubmitBehavior="false"/>
<br /> <br />
</div>
</form>
</body>
Button1.aspx.cs
public partial class FormObjectExamples_Button1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("~/Default.aspx");
}
}
Button2.aspx
<body>
<form id="form1" runat="server">
<div>
You typed in the text box: <asp:Label ID="lblResponse" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
Button2.aspx.cs
public partial class FormObjectExamples_Button2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
string[] s = Request.Form.GetValues("tb");
lblResponse.Text = s[0];
}
catch
{
lblResponse.Text = "No values passed";
}
}
}
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.postbackurl.aspx – MSDN documentation for PostBackUrl.
http://msdn.microsoft.com/en-us/library/ha6ek77t – MSDN documentation for Button object.