.Net Practical 17


Practical : 17
Subject : .Net

Aim : Write a program to check whether empty query string is entered in Asp.Net.



Source Code :
//file.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pra17.aspx.cs" Inherits="dotnet008asp.pra17" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>pratik008</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:Label ID="lblname" runat="server" Text="Name"></asp:Label>
        <asp:TextBox ID="txtname" runat="server"></asp:TextBox>
        <asp:Button ID="btnsubmit" runat="server" OnClick="Button1_Click" Text="submit" />
        <asp:Label ID="lblmsg" runat="server" Text="Label" Visible="False"></asp:Label>
    </form>
</body>
</html>

//file.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace dotnet008asp
{
    public partial class pra17 : System.Web.UI.Page
    {
        protected void Button1_Click(object sender, EventArgs e)
        {
            string name=txtname.Text;
            if (string.IsNullOrEmpty(name))
            {
                lblmsg.Text = "Empty string enterd";
            }
            else
            {
                lblmsg.Text = "Welcome " + name;
            }
            lblmsg.Visible = true;
        }
    }
}

Output :


Pratik Boghani

Author & Editor

Life is all about the next step.

0 comments:

Post a Comment