"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Thursday, December 19, 2013

Using linq and lambda expression in c#

using linq and lambda expression in c#

using linq and lambda expression in c# to filter data.


  • Select all
  • Select some filed
  • Select filtering data with condition
  • Select Anonymous Type / Casting
  • Merging two columns
  • Ordering
  • Joining two list
  • Skip and Take 


Monday, November 11, 2013

button click event not fire from jquery dialog

button click event not fire from JQUERY dialog


Its a common issues.the defalut value of button property "UseSubmitBehavior" is true.

That expresses the button will use the browser's submit mechanism. However, jQuery Dialog UI is manipulating it.

There exists a conflict. If you want to fired the button click event. Please set its property "UseSubmitBehavior" as false.

<asp:Button ID="Button1" runat="server" Text="Button"  UseSubmitBehavior="false" OnClick="Button1_Click" />


If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Thursday, November 7, 2013

Pagging in sql

In one of my older post i posted about  paging in sql using Row_Number function (http://simplyasp.blogspot.in/2010/11/paging-records-using-sql-server-2005.html).on latest version of sql they had improved the paging functionality by bothe performance base and also in readbility base too. on 2008  they introduce CTE (Common table expression) and Derived table.  on sql 2012 they done a mass step on that FETCH NEXT functionality ... i love that.

Below i show all the method of paging i mentioned above.

--SQL 2005/2008 Paging Method Using Derived Table
DECLARE @Start INT
DECLARE @End INT
SELECT @Start = 14000,@End = 14050

 
SELECT LastName, FirstName, EmailAddress
FROM (SELECT LastName, FirstName, EmailAddress,
      ROW_NUMBER() OVER (ORDER BY LastName, FirstName, EmailAddress) AS RowNumber
      FROM Employee) EmployeePage
WHERE RowNumber > @Start AND RowNumber <= @End
ORDER BY LastName, FirstName, EmailAddress
GO

 
--SQL 2005/2008 Paging Method Using CTE
DECLARE @Start INT
DECLARE @End INT
SELECT @Start = 14000,@End = 14050;

 
WITH EmployeePage AS
(SELECT LastName, FirstName, EmailAddress,
 ROW_NUMBER() OVER (ORDER BY LastName, FirstName, EmailAddress) AS RowNumber
 FROM Employee)
SELECT LastName, FirstName, EmailAddress
FROM EmployeePage
WHERE RowNumber > @Start AND RowNumber <= @End
ORDER BY LastName, FirstName, EmailAddress
GO

 
--SQL SERVER 2012
SELECT LastName, FirstName, EmailAddress
FROM Employee
ORDER BY LastName, FirstName, EmailAddress
OFFSET 14000 ROWS

FETCH NEXT 50 ROWS ONLY;

If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Wednesday, October 30, 2013

linq to loop through datatable c#

Iterating through a data table using linq in c#

i faced a criteria to trim a row value with some criteria,

Before trimming

 



After trimming















C# Code





If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Tuesday, September 24, 2013

Monday, September 23, 2013

Action Delegates in c#

In my last post i shown FUNC Delegates now going around ACTION delegates
        
            Action instance can receive parameters, but cannot return values.
 Example below:
  1. How to execute a line
  2. How to execute a method

Thursday, September 19, 2013

Wednesday, September 18, 2013

SQL Function return SQL TABLE


using table values parameter we can achieve it

Function :

CREATE FUNCTION FunctionName
(
@id INT
)
returns table as
return
(
Select * from TableName WHERE id=@id
)

How to call:

select * from FunctionName(1)

If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Tuesday, September 17, 2013

HAPPY ONAM 2013


I Wish You A Very Happy Onam,
May The God Bless You And Fill Your Heart
With Joy & Happiness.
May The Color And Lights Of Onam Fill Your Home
With Happiness And Joy.
Have The Most Beautiful Onam.





Monday, July 15, 2013

Accessing active directory using c#

Hi *.*,
Today i'm sharing a snippet to Accessing active directory using c#. i had created a class file for modular access.Here it goes



using System;
using System.DirectoryServices.AccountManagement;
using System.DirectoryServices;
using System.Configuration;
using System.Collections.Generic;

Thursday, July 4, 2013

Tutorial for Visual Studio Zen Coding

Visual Studio Zen Coding is a visual studio plugin for high-speed HTML, XML, XSL (or any other structured code format) coding and editing.

Just type HTML tag in zen syntax and press alt + z to expand tag to normal form. Its so smooth as touching a flower.

Visual Studio Zen Coding 2012

Thursday, June 27, 2013

Sanitize database inputs

A lesson to all developers 
Sanitize database inputs
 


If u had any trouble just ask, Happy to help u :)
 Stay Tune... Have a nice day... 'N happy Coding :)

Sunday, April 21, 2013

call C# dll using Javascript ActiveX Object

call C# dll using Javascript ActiveX Object

I got a chance to work with siebel crm . The Version they were using is working with ActiveX Object. My objective is we had a dll which has been created in .net class library output.I need to call that library using javascript and do some functionality. Here i'm sharing how i communicate dll with ActiveX using javascript.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

Friday, April 19, 2013

Retrieve data from sugarcrm using c# api with conditional query

Retrieve data from sugarcrm using c# api with conditional query


Before going through this module i strongly recommend to go through my previous post abt this topic as i'm writing as a continuation its difficult to get in track for new readers. Previous Post

create an instance of the dll

  SugarCRMCL.SugarSOAP.sugarsoap client = new SugarCRMCL.SugarSOAP.sugarsoap();

To reterive data



NB: While using query keep in mind that its key sensitive 


If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Tuesday, April 9, 2013

Login Using Sugar API in asp.net c#

Hi *.*,

Before going through this module i strongly recommend to go through my previous post abt this topic as i'm writing as a continuation its difficult to get in track for new readers. Previous Post

Create an instance of the dll we refereed.


  SugarCRMCL.SugarSOAP.sugarsoap client = new SugarCRMCL.SugarSOAP.sugarsoap();


Login Module


Your password should be encrypted before sending to the crm. Sample encryption method below



If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Monday, April 8, 2013

Passing store procedure result to another store procedure as parameter

Passing store procedure result to another store procedure as parameter

-- First Stored ProcedureCREATE PROCEDURE SquareSP@MyFirstParam INT
AS
DECLARE 
@MyFirstParamSquare INT
SELECT 
@MyFirstParamSquare @MyFirstParam*@MyFirstParam-- Additional CodeRETURN (@MyFirstParamSquare)GO

sugar crm api using c# (Consuming soap service)

Hi *.*,
From last one month i was on air.fully after sugar crm api.my job was to create UI on .NET by consuming there api.As i get into the api i realized there no working sample or anything they providing for .net.Using custom class output for service some really stupid stuff.Now i remember a comment abt this crm in sourceforge.net
 very little support & stability has been present in the open source version - very disappointing
Its really unfortunate!!!!! but my client need that. :( Anyway i completed the project with lot of effort and pain. Even in my first project i didn't have this much mental load.Here i'm posting some of the basic steps.

Create a class library project [sample name i used sugarCRMCL]. build the solution first.
Right click on project file and click on add service reference >> Click on advanced




>> add web reference  
Add the service url at the text-box and hit enter key 





























Click on add reference. Build your solution once and get the dll file from bin >>debug folder.

Now create new asp.net project environment. add that dll as reference to the bin folder.



On next day lets go with Login module  :)



Wednesday, March 13, 2013

Disable Cut copy and Paste on a textbox

 Disable Cut copy and Paste on a textbox
 <asp:TextBox ID="TextBox3" runat="server"
onCopy=”return false” onDrag=”return false” onDrop=”return false” onPaste=”return false” oncut="return false">

</asp:TextBox>

If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Friday, February 22, 2013

Scroll text on webpage


Scroll text on webpage

Front end

<table width="100%" cellspacing="0px" cellpadding="0px" class="NewsBgColor">
    <tr>

Tuesday, February 19, 2013

2 hrs in my life

Today i gone for blood donation with my colleagues in RCC (Regional cancer center, Trivandrum,Kerala,India).That my first blood donation.After giving blood i gone unconscious.I really done know what happened to me.After sometime i find myself sitting in a bed near by an air cooler and i'm tired.I feel so bad and why should i be here...for an unknown ??? !!!.Worst day of my life ever. i lost more than 1 and half office hour.Today i cant be 8 hr in office otherwise i need to cancel my movie ticket.After half an hour i feel good and plan to leave the RCC. Then one of my colleagues introduced me to the donor's parents.My eyes suddenly catch the mom's eyes.That filled with tears and saying million thanks to me.i'm freezed. On way back to office i promised myself, will be back here after 3 months.

Monday, February 18, 2013

Monday, February 11, 2013

Bind Dropdown on Footer templete


protected void grdRequestHandling_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.Footer)
                {
                    DropDownList dropdown = e.Row.FindControl("ddlAddRole") as DropDownList;

                    dropdown.DataSource = objBL.GetRoles();
                    dropdown.DataTextField = "RoleName";
                    dropdown.DataValueField = "RoleId";
                    dropdown.DataBind();
                }
            }
            catch (Exception)
            {
               
            }
        }


If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Thursday, February 7, 2013

decrypt a string in javascript which encrypted in c#

encrypted in string in c# and decrypt that in JavaScript


Code behind  
protected void Page_Load(object sender, EventArgs e)
    {
        Hdn.Value = "sdsd".EncodeTo64();
    }

Wednesday, February 6, 2013

auto resize jquery ui dialog box



$('#AddStage').dialog({ modal: true, "width": "auto" });


"width""auto"
don't forgot to all necessary js and css files

If u had any trouble just ask, Happy to help u :)
Stay Tune... Have a nice day... 'N happy Coding :)

Monday, February 4, 2013

get current date in storeprocedure

cast(getdate() as date)
simple and sexy isit?

If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Sunday, February 3, 2013

Moving focus around the table in Jquery

Last week i answered a question in a fourm ( http://forums.asp.net/p/1877841/5281857.aspx/1?How+can+I+move+the+focus+around+my+html+table+ ) to move focus around the cells in a table using jquery . i go with keypress event. below it goes.

Friday, February 1, 2013

addition operation in Grid inside the text box using javascript

Having addition operation on gridview in JavaScript.


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

Wednesday, January 30, 2013

Remove Duplicate Row from datatable in c#

As i was also unaware of this feature until i read as answer in fourms.asp.net (link). Previously i was achieved by using lambda expression.Now no need to those just one line code :)


DataTable dt = new DataTable
        {
            Columns ={
                {"Myid",typeof(int)},
                {"Name"},
                {"Address"}
                }
        };
        dt.Rows.Add(1, "Arun Aravind", "Kollam");
        dt.Rows.Add(1, "Arun Aravind", "Kollam");
        dt.Rows.Add(2, "Arun Aravind", "Kollam");
        dt.Rows.Add(2, "Arun Aravind", "Kollam");
        dt.Rows.Add(3, "Arun Aravind", "Kollam");

        dt = dt.DefaultView.ToTable(false, "Address", "Name", "Myid");

Output




If u had any trouble just ask, Happy to help u :)
Stay Tune... Have a nice day... 'N happy Coding :)

Tuesday, January 29, 2013

Changing image within Gridview programatically

Simple RowdataBound event isit? an alternate if it reduce memory load and time. wht abt that :)
Yup by jquery :)

Monday, January 28, 2013

Reflection in c#

After a series of post regarding caches, we are into reflection now.
Here i'm posting how to invoke a method,Getting events properties,fields from a class using reflection.

For that i created a console application  ( named : ReflectionConsoleApplication ) and invoke using System.Reflection; Namespace and created a class and code goes below.

Sunday, January 27, 2013

Exploring more in cache in asp.net-- remove cache-- part 5

I covered a few topic about cache in asp.net except one how to remove a cache :)

HttpContext.Current.Cache.Remove("customers"); // customers my cache name


If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Saturday, January 26, 2013

Exploring more into caching in asp.net-- Data Caching (Part 4)


ASP.NET also supports caching of data as objects. We can store objects in memory and use them across various pages in our application. This feature is implemented using the Cache class. This cache has a lifetime equivalent to that of the application. Objects can be stored as name value pairs in the cache. A string value can be inserted into the cache as follows:


Cache["name"] = "Arun Aravind";

 The stored string value can be retrieved like this:


if (Cache["name"] != null)
            Label1.Text = Cache["name"].ToString();
 
To insert objects into the cache, the Add method or different versions of the Insert method of the Cache class can be used. These methods allow us to use the more powerful features provided by the Cache class.


protected void Page_Load(object sender, EventArgs e)
    {
        ArrayList datestamps;
        if (Cache["datestamps"] == null)
        {
            datestamps = new ArrayList();
            datestamps.Add(DateTime.Now);
            datestamps.Add(DateTime.Now);
            datestamps.Add(DateTime.Now);

            Cache.Add("datestamps", datestamps, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 0, 60), System.Web.Caching.CacheItemPriority.Default, null);
        }
        else
            datestamps = (ArrayList)Cache["datestamps"];

        foreach (DateTime dt in datestamps)
            Response.Write(dt.ToString() + "<br />");
    }


If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)