Skip to main content

Featured Post

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

How to Hide web application code from users in ASP.NET

If we talk about web application projects then we simply says that each presentation page attach with code behind page(where you can design your business logic code). If you are a developer and you want to sell your project without code then you will hide its business logic code behind the ".DLL" (dynamic link library) file.
There are available some steps to do this task.
These are
  1. Create a web application project (file--new project--Visual C# --Web -- ASP.NET web Form application)
  2. Write project name, which you want, In this article we take "hide code" as a project name.
new web project in asp.net

3. Delete all directories from the solution explorer. Because i want to design only business logic code, after coding we will create DLL file for this. For this you should attach a class file in this project. Take a look after deleted all files from solution explorer.

deleted all files from solution explorer.

4.  Now, we learn how to attach a class file in the project. Select "add new item" from context menu by right clicking on project name.
Select "add new item"

Now, here appear a new window. In this window select code in left panel and also select class in the right panel.
 select code in left panel and also select class in the right panel.

5.  Write the business logic code for display message on the screen, so we raise a button handler code in displayResult class.
You can design your code for multiple classes through this approach we will create a business logic model. Suppose i want to create a small application for employee, in which i want to display data of employee also display employee salary. Application hold two function first for employee data and second for employee salary. Similarly through this code i want to display "Hello World!" message on the browser. Now your code look like
business logic model

In the above mentioned snap displayResult class inherits from page class, page class contains some object like response,request etc. if you want to use page objects then created class must be inherits from Page class. Also mentioned two namespace, first is System.Web.UI and other is System.Web.UI.WebControls.
6.  Build the solution by selecting "Build HideCode" from Build Tab.
Build the solution by selecting "Build HideCode"

Now your .DLL file has made in Bin folder of the project. File contains single namespace(HideCode) , class(displayResult) and single method(displayresult( )).
7. Now add new project in the solution by right clicking on solution name. Select ASP.NET Web form application project in appeared window also write name of the project, i keep presentation part as a project name. Now your solution explorer contains two project, see below
solution explorer contains two project

8.  Now add new web form in the project also change the name of it, i keep  "presentationpage.aspx" as a project name. This page is basically used for designing purpose. Through this page we can call method of other projects, but will do some changes in the page . Before doing this, first of all add above mentioned project reference in the current project. Learn how to add reference in the project.
Note : Remove all attached file from this page.
 Remove all attached file from this page

(a) Add Reference by right click on References link. select Solution from the appeared window also select .dll checkbox which is appeared in right panel of it.
select .dll checkbox which is appeared in right panel

9. Remove "CodeBehind" attribute from presentation page also add inherits attribute in the page directive. Assign namespace , which is created in earlier project  with class name. Look like
 Remove "CodeBehind" attribute

10. Add button in the page also raise onclick event on it. Call displayresult( ) method, which is created in business logic code. now your code look like
<%@ Page Language="C#" AutoEventWireup="true" Inherits="HideCode.displayResult" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="hide coding" OnClick ="displayresult" />
</div>
</form>
</body>
</html>

Now your code generate the following output

How to Hide web application code from users in ASP.NET

First code of line define the page directive. In this line,you must to add namespace with class name in inherits attribute. After that you can access methods and properties of that class. In this code i also access method of displayResult class using Button click event.

Comments

Popular Post

Polynomial representation using Linked List for Data Structure in 'C'

Polynomial representation using Linked List The linked list can be used to represent a polynomial of any degree. Simply the information field is changed according to the number of variables used in the polynomial. If a single variable is used in the polynomial the information field of the node contains two parts: one for coefficient of variable and the other for degree of variable. Let us consider an example to represent a polynomial using linked list as follows: Polynomial:      3x 3 -4x 2 +2x-9 Linked List: In the above linked list, the external pointer ‘ROOT’ point to the first node of the linked list. The first node of the linked list contains the information about the variable with the highest degree. The first node points to the next node with next lowest degree of the variable. Representation of a polynomial using the linked list is beneficial when the operations on the polynomial like addition and subtractions are performed. The resulting polynomial can also

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

Memory representation of Linked List Data Structures in C Language

                                 Memory representation of Linked List              In memory the linked list is stored in scattered cells (locations).The memory for each node is allocated dynamically means as and when required. So the Linked List can increase as per the user wish and the size is not fixed, it can vary.                Suppose first node of linked list is allocated with an address 1008. Its graphical representation looks like the figure shown below:       Suppose next node is allocated at an address 506, so the list becomes,   Suppose next node is allocated with an address with an address 10,s the list become, The other way to represent the linked list is as shown below:  In the above representation the data stored in the linked list is “INDIA”, the information part of each node contains one character. The external pointer root points to first node’s address 1005. The link part of the node containing information I contains 1007, the address of