Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Tuesday, 14 July 2015

In this article I have explain how to show Textbox value in Label Control on button click. This article may helpful for beginners.
Implementation:
Add a new webpage in your application. Now Place a textbox control on page. Thena add a button and label control to the page.

Source code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>  
</head>
<body>
    <form id="form1" runat="server">
    <fieldset style="width:400px"><legend><strong>Show Entered value in Label Control</strong></legend>
    <div>
   
        <table >
            <tr>
                <td >
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td >
                    Entyer Value</td>
                <td>
                    <asp:TextBox ID="txtvalue" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td >
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style3">
                </td>
                <td class="style4">
                    <asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click"
                        Text="Submit" />
                </td>
            </tr>
            <tr>
                <td >
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td >
                    Display Entered value</td>
                <td>
                    <asp:Label ID="lblShow" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
        </table>
   
    </div></fieldset>
    </form>
</body>
</html>


ASP.NET code Using c#:

public partial class insert : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (txtvalue.Text.Trim().Length > 0)
        {
            lblShow.Text = txtvalue.Text;
        }
        else
        {
            lblShow.Text = "Enter value in text box";
        }
    }
}

 VB.NET code:
Partial Class vb
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        If txtvalue.Text.Trim().Length > 0 Then
            lblShow.Text = txtvalue.Text
        Else
            lblShow.Text = "Enter value in text box"
        End If
    End Sub
End Class


Use this code in your application and check result. 
Categories: , , , ,

0 comments:

Post a Comment