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

Pages

Monday, December 31, 2012

Welcome 2013

There are things that are sometimes left undone and there are things that can be left sometimes unsaid. There are things that can be sometimes left unsaid, but wishing someone like you can't ever be left, so I take this moment to wish you and your loved ones a joyous and wonderful New Year.


Modified info window in google maps :)



 Modified info window in Google maps :)

























Saturday, December 22, 2012

Call Client Side JavaScript function() from Server Side

Call Client Side JavaScript function() from Server Side

You can find million of forums with same question and answers.Last day i cn a post in codeproject by P.Salini. Given a well documented solution for it.

Wednesday, December 19, 2012

Substitution Web Server Control

Substitution Web Server Control last day i heard abt this :( ( 'm also a programmer)while i referring abt asp cache it know abt this controller pretty good too.Its from .net 2.0 too latest

Use the Substitution control to specify a section of an output-cached Web page where you want to display dynamic content. The Substitution control offers a simplified solution to partial page caching for pages where the majority of the content is cached. You can output-cache the entire page, and then use Substitution controls to specify the parts of the page that are exempt from caching. Cached regions execute only once and are read from the cache until the cache entry expires or is purged. Dynamic regions execute every time that the page is requested. This caching model simplifies the code for pages that are primarily static, because you do not have to encapsulate the sections to cache in Web user controls. For example, this caching model is useful in a scenario where you have a page that contains static content, such as news stories, and an AdRotator control that displays advertisements. The news stories do not change frequently, which means that they can be cached. However, every time that a user requests the page, you want to display a new advertisement. The AdRotator control directly supports post-cache substitution and renders a new advertisement every time that the page posts back, regardless of whether the page is cached.

When an ASP.NET page is cached, by default the entire output of the page is cached. On the first request, the page runs and caches its output. On subsequent requests, the request is fulfilled from the cache and code on the page does not run.

In some circumstances, you might want to cache an ASP.NET page but update selected portions of the page on every request. For example, you might want to cache the majority of a page but be able to dynamically update time-sensitive information on the page.

You can use the Substitution control to insert dynamic content into the cached page. The Substitution control does not render any markup. Instead, you bind the control to a method on the page or on a parent user control. You create a static method that returns the information that you want to insert into the page. The method called by the Substitution control must meet the following criteria:

    It must be a static method (shared in Visual Basic).

    It must accept a parameter of type HttpContext.

    It must return a value of type String.

Other controls on the page are not accessible to the Substitution control—that is, you cannot examine or change the value of other controls. However, the code does have access to the current page context by using the parameter passed to it.

When the page runs, the Substitution control calls the method and then substitutes the return value from the method for the Substitution control on the page.

(content ripped from msdn :: http://msdn.microsoft.com/en-us/library/ms228212%28v=vs.100%29.aspx)
example




<%@ Page Language="C#" AutoEventWireup="true" CodeFile="subsitituation.aspx.cs" Inherits="subsitituation" %>
<%@ OutputCache Duration="60" VaryByParam="None" %>
<script runat="server" language="C#"> 

  void Page_Load(object sender, System.EventArgs e)
  {
    // Display the current date and time in the label.
    // Output caching applies to this section of the page.
    CachedDateLabel.Text = DateTime.Now.ToString();   
  }

  // The Substitution control calls this method to retrieve
  // the current date and time. This section of the page
  // is exempt from output caching.
  public static string GetCurrentDateTime (HttpContext context)
  {
    return DateTime.Now.ToString ();
  }

</script>
<!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 id="Head1" runat="server">
  <title>Substitution Class Example</title>
</head>
<body>
  <form id="form1" runat="server">

    <h3>Substitution Class Example</h3> 

    <p>This section of the page is not cached:</p>

    <asp:substitution id="Substitution1"
      methodname="GetCurrentDateTime"
      runat="Server">
    </asp:substitution>

    <br />

    <p>This section of the page is cached:</p>

    <asp:label id="CachedDateLabel"
      runat="Server">
    </asp:label>

    <br /><br />

    <asp:button id="RefreshButton"
      text="Refresh Page"
      runat="Server">
    </asp:button>    

  </form>
</body>
</html>

 

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

Tuesday, December 18, 2012

Optional parameter and Named Argument in asp.net c#

Optional parameter and Named Argument in asp.net c#

I viewed in few blogs they are passing parameter to methods by comma separated null value and also in particular where parameter defined. By 3.5 or 4.0 (not clear) .net introduced Optional parameter and Named Argument.

Monday, December 17, 2012

Better way for multiple optional search in sql Store Procedure

Better way for multiple optional search in sql Store Procedure

i assigned multiple optional search to my junior resources a few weeks ago recently i gone through the code standards I'm bit surprised every one is different :) . they gone through row-filtering,Dynamic sql,where case in sql,Table search,IF IS NULL in sql ...

Friday, December 14, 2012

Get Store Procedure,User Table,System Table,Primary Key,Scalar Function Create date and modification date in SQL SERVER

Get Store Procedure,User Table,System Table,Primary Key,Scalar Function Create date and modification date in SQL SERVER



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

Thursday, December 13, 2012

Wednesday, December 12, 2012

LEN and DATALENGTH in SQL Server

Difference between LEN and DATALENGTH in SQL Server

Len will trim the end of the string and count the length where as  DATALENGTH just count the lenght,its doesn't trim :)

Below sample query and example

Sunday, December 2, 2012

Count of duplicate record in dataset or datatable



Count of duplicate record in dataset or datatable in C# 


   DataTable dtList = dtduplicate();

        DataTable dt = ds.Tables[0];
      
        var result = from c in dt.AsEnumerable()
                     group c by new
                     {
                         ClientID = c.Field<string>("ClientID"),
                         CurrentServicerLoanNo = c.Field<string>("CurrentServicerLoanNo"),
                         CurrentLoanServicer=c.Field<string>("CurrentLoanServicer"),
                         NameOfOriginatingLender=c.Field<string>("NameOfOriginatingLender"),
                         OriginalLoanNumber=c.Field<string>("OriginalLoanNumber")
                     } into g
                     where g.Count() > 1
                     select new
                     {
                        
                         g.Key.ClientID,
                         g.Key.CurrentServicerLoanNo,
                         g.Key.CurrentLoanServicer,
                         g.Key.NameOfOriginatingLender,
                         g.Key.OriginalLoanNumber,
                         Noofrec = g.Count()
                     };

for (int i = 0; i < result.ToList().Count; i++)
        {
            var item = result.ToList()[i];
            //   resultTable.Rows.Add(item.ProdId, item.Pin, item.Noofrec);
            dtList.Rows.Add(null,item.ClientID, item.CurrentLoanServicer, item.CurrentServicerLoanNo, item.NameOfOriginatingLender, item.Noofrec, item.OriginalLoanNumber);
        }

   public static DataTable dtduplicate()
    {
        DataTable dtDuplicatelist = new DataTable();

        DataColumn auto = new DataColumn("AutoID", typeof(System.Int32));
        dtDuplicatelist.Columns.Add(auto);
        auto.AutoIncrement = true;
        auto.AutoIncrementSeed = 1;
        auto.ReadOnly = true;
        auto.Unique = true;


        dtDuplicatelist.Columns.Add("ClientID", typeof(string));
        dtDuplicatelist.Columns.Add("CurrentLoanServicer", typeof(string));
        dtDuplicatelist.Columns.Add("CurrentServicerLoanNo", typeof(string));
        dtDuplicatelist.Columns.Add("NameOfOriginatingLender", typeof(string));
        dtDuplicatelist.Columns.Add("Noofrec", typeof(string));
        dtDuplicatelist.Columns.Add("OriginalLoanNumber", typeof(string));

        dtDuplicatelist.PrimaryKey = new DataColumn[] { auto }; // Setting as primary key Then only it will add autoincrement to the Column
        return dtDuplicatelist;
    }

 



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