Search This Blog

Thursday, November 14, 2013

Fix div at the bottom of the page

HTML > DIV > Fix at the bottom of the page





<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    Content
    <div style="position: fixed; bottom: 0px;">
        This is div fixed at the bottom of the page</div>
</body>
</html>
 
 

Create new WCF Service Application Example

WCF > Create WCF application

Example: use WCF method to return connection string to windows forms application in order to protect discover sensitive data using decompiling software.






1. Create new WCF Service Application

Start New Project > WCF > WCF Service Application



Go to Web.config file and set directoryBrowse to false to avoid directory browsing.

<directoryBrowse enabled="false"/>

2. Add your own methods

Open IService1.cs and add method GetConnString method


     public interface IService1
     {
        [OperationContract]
        string GetData(int value);
        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);
 

        // TODO: Add your service operations here

        [OperationContract]
        string GetConnString(string username);
    }

Open Service1.svc and add method GetConnString
 

 
    public string GetConnString(string username)
    {
            string connstring = "Your connection string set in Wcf Service";
            // check user, etc
            return connstring;
    }
  

Press F5 and than stop  debugging.
   
3. Create new Windows Form  Application in the same solution



Go to Service reference and add (press Discover button!)



Set this project as Start-up project in your solution.

Add the following code:

ServiceReference1.Service1Client sc = new ServiceReference1.Service1Client();
MessageBox.Show(sc.GetConnString("xxx"));

Run your application:






How to set a value of char to null?

C# > Char > Null value

char filter = '\0';






Wednesday, November 13, 2013

=> Operator (lambda)

C# > Operators > => Lambda Operator 

The => operator is called the lambda operator. 
It is used in lambda expressions to separate the input variables on the left side from the lambda body on the right side.
                   (input parameters) => expression
The parentheses are optional only if the lambda has one input parameter, otherwise they are required:
             (x, y) => x == y
Zero input parameters with empty parentheses:

                    () => MyMethod()

Examples

1. Power

delegate int Power(int i);

Power myDelegate = x => x * x;
int j = myDelegate(7); //j = 49

MessageBox.Show(j.ToString());

2. Lambda expressions in query














DataSet C#

C# > System.Data   > DataSet

DataSet represents an in-memory cache of data.
DataSet consists of a collection of DataTable objects.

Example:











SqlCommand C#

C# > Data > SqlCommand

SqlCommand is a Transact-SQL statement or stored procedure to execute against a SQL Server database.









Tuesday, November 12, 2013

GridBoundColumn RadGrid Telerik

Telerik > RadGrid > GridBoundColumn


GridBoundColumn is bound to a field in a data source.

Properties


Example:

GridBoundColumn staticColumn = new GridBoundColumn();
staticColumn = new GridBoundColumn();
staticColumn.DataField = "Title";
staticColumn.HeaderText = "Title";
grd.Columns.Add(staticColumn);