Monday 9 October 2017

Asp.net lesson-6

ASP.NET LESSON-6


CREATE A WEBPAGE AS BELOW.

Sample web form.










<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
  <b>  user Name:</b>
        <asp:TextBox ID="username" runat="server">

        </asp:TextBox>
        <p>
            <b>comments: </b>
            <asp:TextBox TextMode ="MultiLine" Rows ="5" Columns ="25" ID="comments" runat ="server"></asp:TextBox>
        </p>
        <p>
            <asp:Button ID="submit"  Text ="submit" runat ="server" OnClick="submit_Click" />
        </p>
        <p>
            <asp:Label ID="lbloutput" runat ="server"
                ></asp:Label>
        </p>
    </div>
    </form>
</body>
</html>
Program Explanation:
In the above program we just simply added a text box, a multiline textbox, a button and a output label.
The second text box become a multiline text box because we have assigned the attribute textmode=”Multiline”..
We have to give our name and comments in the output screen and we will have to click button
  protected void submit_Click(object sender, EventArgs e)
    {
        lbloutput.Text = "Thank you" + username.Text + "for the following comments<br>" +"<tt>"+ comments.Text+"</tt>";

    }
}
To add submit_Click() method follow the rules.

1.  Select button and press f4
2.  Property box window will display.
3.  In the below as indicated select lightning icon.
4.  put the cursor at the property box In the click event and double click
5.  now a new window opens and type the code in submit_Click method.






Output:




No comments:

Post a Comment