| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Lecture - Form Objects - Buttons

Page history last edited by Dr. Ron Eaglin 8 years, 6 months ago

 Buttons Part 1 and Buttons Part 2

 

 

Prerequisites

 

Lecture - Getting Started in Visual Studio

 

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.

 

 

Additional Information

 

 

COP 4834 Lectures Page

Comments (0)

You don't have permission to comment on this page.