Click here to Skip to main content
15,894,337 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a program written in C sharp that reads data from a SQL Express database. One of the fields in one of the tables is encrypted with my own encryption method. I just got a bright idea to create a ASP.Net page so I could access the data from my Ipad. I have been playing around with the DOT Net page, and have it so I can read the data from the server. What I need now is a way to run the output from the server through my encryption method so the data will display in straight text on the aspx page. I want to add the method to the aspx page and call it before the data is bound to the grid. Anyone with any ideas? Thanks
Everett
Posted
Comments
PeejayAdams 31-Dec-14 10:17am    
Can you not just put it the Page_Load event handler?
Sergey Alexandrovich Kryukov 31-Dec-14 14:26pm    
What does it mean, exactly? Call from what element of the page?
—SA

1 solution

In ASP.NET you can use your code-behind (A.K.A C# classes) by putting them into a special ASP.NET folder, known as App_Code. All of your logic, to describe the working of the objects in your application must be put their, if you're going to have any library (.dll files) then you must add it to the bin folder.

Once there, you can easily call your objects into the aspx page, by adding a reference to the namespace of your project (if the namespace of class file and your ASP.NET project doesn't match) like this,

C#
using MyClassFiles;


.. then, you can call the methods and property of them in your aspx page, as you would in any other application written in C#.

I would like to recommend, when you're working with ASP.NET you must try to ignore writing the business logic of your application (main code) inside the aspx page where you're going to render the HTML. Instead, you must create these objects in the code-behind and just call the functions and methods. Also, you must try to return only the string that would indicate success or error.
 
Share this answer
 
Comments
Everetts 1-Jan-15 9:07am    
Thanks for the reply. I have decided that since this will involve user id and password, I don't want to send either in plain text over the internet. Thanks again
Everett

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900