WCF Application and Instance Management by using 3 different application domains (Asp.net, C # Windows Application and WPF application as clients) -- Part 2

Previous article 1

Part-2 Creating ASP.net client.

Code for ASP.net Client

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data.SqlClient;

using System.Data;

public partial class _Default : System.Web.UI.Page

{

ServiceReference1.IService PersonalInfo = new ServiceReference1.ServiceClient();

ServiceReference1.PersonalInfo Pi = new ServiceReference1.PersonalInfo();

DataTable dt = new DataTable();

 

protected void Page_Load(object sender, EventArgs e)

{

dt = new DataTable();

Pi.p_name = "Ankit";

dt = PersonalInfo.GetPersonalInfo(Pi);

 

gdvVW.DataSource = dt;

gdvVW.DataBind();

TextBox1.Text = Convert.ToString(Convert.ToString(PersonalInfo.ReturnVal()));

}

protected void btnSearch_Click(object sender, EventArgs e)

{

dt = new DataTable();

Pi.p_name = txtName.Text;

dt = PersonalInfo.GetPersonalInfo(Pi);

 

gdvVW.DataSource = dt;

gdvVW.DataBind();

TextBox1.Text = Convert.ToString(Convert.ToString(PersonalInfo.ReturnVal()));

}

}

 

Code for .aspx file

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

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Asp.net Client</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<table>

<tr>

<td colspan="3" style="font-size:x-large; text-align:center">DEV Techie</td>

</tr>

<tr>

<td>

<asp:Label ID="lblEnterName" runat="server" Text="Enter Name"></asp:Label>

</td>

<td>

<asp:TextBox ID="txtName" runat="server"></asp:TextBox>

</td>

<td>

<asp:Button ID="btnSearch" runat="server" Text="Search" onclick="btnSearch_Click" />

</td>

 

</tr>

<tr>

<td>

<asp:Label ID="Label1" runat="server" Text="Service Object Count"></asp:Label>

</td>

<td>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>

</tr>

<tr>

<td colspan="4">

<asp:GridView ID="gdvVW" runat="server" ></asp:GridView>

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

 

Below is the page design for ASP.net client

Tags:

ASP.NET | WCF