WCF application for displaying and inserting records into database using Data Contract and Data Member Attributes – Part 5

When we want to use the member variables of class Leader at client side, we will have to declare the object of that class Leader and through that object we will access its members.

Eg.

ServiceReference1.Leaders ldr = new ServiceReference1.Leaders();

 

Aspx code:

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

 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

 

<!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></title>

 

</head>

<body>

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

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>

<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>--%>

<div>

<table>

<tr>

<td><h1>DevTechie</h1></td>

</tr>

<tr>

<td>

<table>

<tr>

<td>

<asp:Label ID="Label1" runat="server" Text="Enter Name of Leader"></asp:Label></td>

<td>

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

</td>

<td>

<asp:Button ID="btnsearch" runat="server" Text="Show Leader"

onclick="btnsearch_Click"/>

</td>

</tr>

</table>

</td>

</tr>

<tr><td>

<asp:GridView ID="GridView1" runat="server">

</asp:GridView>

</td></tr>

 

<tr>

<td>

<asp:Image ID="Image1" runat="server" Height="200px" />

</td>

<td>

<table>

<tr>

<td>

</td>

<td>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table>

<tr>

<td>

<asp:Button ID="btnAddLeader" runat="server" Text="Add New Leader"

onclick="btnAddLeader_Click" />

</td>

<td>

<%--<asp:Button ID="btnModifyLeaderInfo" runat="server" Text="Modify Info Of Leader" />--%>

</td>

</tr>

</table>

</td>

</tr>

<tr><td></td></tr>

<tr>

 

<td>

<asp:Panel ID="Panel1" runat="server" BackColor="Silver" BorderColor="Black"

BorderWidth="2px">

<table>

<tr>

<td>Enter the TextFields</td>

</tr>

<tr>

<td><asp:Label ID="lblName" runat="server" Text="Name"></asp:Label></td>

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

</tr>

<tr>

<td><asp:Label ID="lblCountry" runat="server" Text="Country"></asp:Label></td>

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

</tr>

 

<tr>

<td><asp:Label ID="lblPicture" runat="server" Text="Picture"></asp:Label></td>

<td>

 

<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" />

 

</td>

 

</tr>

<tr>

<td>

<asp:Button ID="btnSaveClose" runat="server" Text="Save And Close" onclick="btnSaveClose_Click" /></td>

</tr>

</table>

</asp:Panel>

 

</td>

 

 

 

</tr>

</table>

<table>

<tr>

<td>

 

 

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1" TargetControlID="btnAddLeader">

 

</asp:ModalPopupExtender>

<%--<asp:PopupControlExtender ID="PopupControlExtender1" runat="server" PopupControlID="Panel1" TargetControlID="btnAddLeader">

</asp:PopupControlExtender>--%>

</td>

</tr>

</table>

</div>

<%-- </ContentTemplate>

</asp:UpdatePanel>--%>

</form>

</body>

</html>

 

Webconfig for client side

<bindings>

<wsHttpBinding>

<binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"

openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"

bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"

maxBufferPoolSize="524288" maxReceivedMessageSize="75536" messageEncoding="Text"

textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">

<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

maxBytesPerRead="4096" maxNameTableCharCount="16384" />

<reliableSession ordered="true" inactivityTimeout="00:10:00"

enabled="false" />

<security mode="Message">

<transport clientCredentialType="Windows" proxyCredentialType="None"

realm="">

<extendedProtectionPolicy policyEnforcement="Never" />

</transport>

<message clientCredentialType="Windows" negotiateServiceCredential="true"

algorithmSuite="Default" establishSecurityContext="true" />

</security>

</binding>

</wsHttpBinding>

</bindings>

 

Note: In the above article we have discussed only basic use of datacontract and datamember attributes but there is more to them which we will be covering in my coming article.

Also we have not discussed anything about instance management which hopefully we will be covering in my coming articles.

 

Jump to: Part 1Part 2Part 3Part 4

Tags:

ASP.NET | WCF