Monday, May 26, 2014

How to get all procedure script in sql server?

select ROUTINE_NAME,ROUTINE_DEFINITION from INFORMATION_SCHEMA.ROUTINES where ROUTINE_TYPE='PROCEDURE' and  ROUTINE_NAME like 'procSCH%'

But after len>4000 is not authenticated

Friday, May 23, 2014

How to hide and show div on click link?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        function showonlyone(thechosenone) {
            var newboxes = document.getElementsByTagName("div");
            for (var x = 0; x < newboxes.length; x++) {
                var name = newboxes[x].getAttribute("class");
                if (name == 'newboxes') {
                    if (newboxes[x].id == thechosenone) {
                        newboxes[x].style.display = 'block';
                      //$(newboxes[x]).slideToggle(1000);
                    }
                    else {
                        newboxes[x].style.display = 'none';
                    }
                }
            }
        }

    </script>
 
</head>
<body>
    <form id="form1" runat="server">
<table>
   <tr>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader1" href="javascript:showonlyone('newboxes1');" >collapse</a>
         </div>
     
      </td>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader2" href="javascript:showonlyone('newboxes2');" >collapse</a>
         </div>
     
      </td>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader3" href="javascript:showonlyone('newboxes3');" >collapse</a>
         </div>
     
      </td>
   </tr>
    <tr>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader4" href="javascript:showonlyone('newboxes4');" >collapse</a>
         </div>
     
      </td>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader5" href="javascript:showonlyone('newboxes5');" >collapse</a>
         </div>
     
      </td>
      <td>
         <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
            <a id="myHeader6" href="javascript:showonlyone('newboxes6');" >collapse</a>
         </div>
     
      </td>
   </tr>
    <tr><td colspan="3">
          <div class="newboxes" id="newboxes1" style="border: 1px solid black; background-color: #CCCCCC; display: none;padding: 5px;">Div #1</div>
          <div class="newboxes" id="newboxes2" style="border: 1px solid black; background-color: #CCCCCC; display: none;padding: 5px;">Div #2</div>
          <div class="newboxes" id="newboxes3" style="border: 1px solid black; background-color: #CCCCCC; display: none;padding: 5px;">Div #3</div>
          <div class="newboxes" id="newboxes4" style="border: 1px solid black; background-color: #CCCCCC; display: none;padding: 5px;">Div #4</div>
          <div class="newboxes" id="newboxes5" style="border: 1px solid black; background-color: #CCCCCC; display: none;padding: 5px;">Div #5</div>
          <div class="newboxes" id="newboxes6" style="border: 1px solid black; background-color: #CCCCCC; display: none;padding: 5px;">Div #6</div>
        </td></tr>
</table>

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

Thursday, May 22, 2014

How to custom paging in datalist?

UI:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
    <title>Custom Paging of DataList - Asp.NET(C#)</title>
   
    <style>
        .btnlink{color: #FFF;font-weight: bold;background-color: red;height: 40px;width: 40px;padding: 2px 10px 2px 10px;text-align: center;border: 2px solid yellow;}
         .btnlP{color: #FFF;font-weight: bold;text-decoration: none;}
         .shopage{color: #FFF;font-weight: bold;background-color: gray;text-decoration: none;
                  height: 40px;width: 100px;padding: 2px 10px 2px 10px;text-align: center;border: 2px solid yellow;}

    </style>
</head>
<body>
    <form id="form1" runat="server">
        <table width="100%">
            <tr>
                <td align="center">
                    <strong>Data List Custom Paging</strong></td>
            </tr>
            <tr>
                <td align="left">
                    <asp:DataList runat="server" ID="dListItems" RepeatColumns="2" CellPadding="2">
                        <ItemTemplate>
                            <%#Eval("title") %>
                        </ItemTemplate>
                        <AlternatingItemStyle BackColor="Silver" />
                        <ItemStyle BackColor="White" />
                    </asp:DataList>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td>
                    <table style="background-color:green;" cellpadding="0" border="0">
                        <tr>
                            <td width="50px" align="right">
                                <asp:LinkButton ID="lbtnFirst" CssClass="btnlP" runat="server" CausesValidation="false" OnClick="lbtnFirst_Click">First</asp:LinkButton>
                                &nbsp;</td>
                            <td width="50px" align="right">
                                <asp:LinkButton ID="lbtnPrevious"  CssClass="btnlP" runat="server" CausesValidation="false" OnClick="lbtnPrevious_Click">Previous</asp:LinkButton>&nbsp;&nbsp;</td>
                            <td  width="200px" align="center" valign="middle">
                                <asp:DataList ID="dlPaging"   runat="server" RepeatDirection="Horizontal" OnItemCommand="dlPaging_ItemCommand"
                                    OnItemDataBound="dlPaging_ItemDataBound">
                                    <ItemTemplate>
                                        <asp:LinkButton   CssClass="btnlink" ID="lnkbtnPaging" runat="server" CommandArgument='<%# Eval("PageIndex") %>'
                                            CommandName="Paging" Text='<%# Eval("PageText") %>'></asp:LinkButton>&nbsp;
                                    </ItemTemplate>
                                </asp:DataList>
                            </td>
                            <td width="50px" align="left">
                                &nbsp;&nbsp;<asp:LinkButton  CssClass="btnlP" ID="lbtnNext" runat="server" CausesValidation="false"
                                    OnClick="lbtnNext_Click">Next</asp:LinkButton></td>
                            <td width="50px" align="left">
                                &nbsp;
                                <asp:LinkButton ID="lbtnLast"  CssClass="btnlP" runat="server" CausesValidation="false" OnClick="lbtnLast_Click">Last</asp:LinkButton></td>
                            <td Class="shopage"  width="100px" align="center" style="height: 30px" valign="middle">
                                <asp:Label ID="lblPageInfo" runat="server"></asp:Label></td>
                        </tr>
                   
                    </table>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
=================
Code behind

==============
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    #region Private Properties
    private int CurrentPage
    {
        get
        {
            object objPage = ViewState["_CurrentPage"];
            int _CurrentPage = 0;
            if (objPage == null)
            {
                _CurrentPage = 0;
            }
            else
            {
                _CurrentPage = (int)objPage;
            }
            return _CurrentPage;
        }
        set { ViewState["_CurrentPage"] = value; }
    }
    private int fistIndex
    {
        get
        {

            int _FirstIndex = 0;
            if (ViewState["_FirstIndex"] == null)
            {
                _FirstIndex = 0;
            }
            else
            {
                _FirstIndex = Convert.ToInt32(ViewState["_FirstIndex"]);
            }
            return _FirstIndex;
        }
        set { ViewState["_FirstIndex"] = value; }
    }
    private int lastIndex
    {
        get
        {

            int _LastIndex = 0;
            if (ViewState["_LastIndex"] == null)
            {
                _LastIndex = 0;
            }
            else
            {
                _LastIndex = Convert.ToInt32(ViewState["_LastIndex"]);
            }
            return _LastIndex;
        }
        set { ViewState["_LastIndex"] = value; }
    }
    #endregion

    #region PagedDataSource
    PagedDataSource _PageDataSource = new PagedDataSource();
    #endregion

    #region Private Methods
    /// <summary>
    /// Build DataTable to bind Main Items List
    /// </summary>
    /// <returns>DataTable</returns>
    private DataTable GetDataTable()
    {
        DataTable dtItems = new DataTable();

        DataColumn dcName = new DataColumn();
        dcName.ColumnName = "title";
        dcName.DataType = System.Type.GetType("System.String");
        dtItems.Columns.Add(dcName);

        DataRow row;
        for (int i = 1; i <= 100; i++)
        {
            row = dtItems.NewRow();
            row["title"] = "Sample Row:&nbsp;I am putting here sample text for row " + i;
            dtItems.Rows.Add(row);

        }
        return dtItems;

    }

    /// <summary>
    /// Binding Main Items List
    /// </summary>
    private void BindItemsList()
    {

        DataTable dataTable = this.GetDataTable();
        _PageDataSource.DataSource = dataTable.DefaultView;
        _PageDataSource.AllowPaging = true;
        _PageDataSource.PageSize = 10;
        _PageDataSource.CurrentPageIndex = CurrentPage;
        ViewState["TotalPages"] = _PageDataSource.PageCount;

        this.lblPageInfo.Text = "Page " + (CurrentPage + 1) + " of " + _PageDataSource.PageCount;
        this.lbtnPrevious.Visible = !_PageDataSource.IsFirstPage;
        this.lbtnNext.Visible = !_PageDataSource.IsLastPage;
        this.lbtnFirst.Visible = !_PageDataSource.IsFirstPage;
        this.lbtnLast.Visible = !_PageDataSource.IsLastPage;
        this.dListItems.DataSource = _PageDataSource;
        this.dListItems.DataBind();
        this.doPaging();
    }

    /// <summary>
    /// Binding Paging List
    /// </summary>
    private void doPaging()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("PageIndex");
        dt.Columns.Add("PageText");

        fistIndex = CurrentPage -3;


        if (CurrentPage > 3)
        {
            lastIndex = CurrentPage +3;
        }
        else
        {
            lastIndex = 5;
        }
        if (lastIndex > Convert.ToInt32(ViewState["TotalPages"]))
        {
            lastIndex = Convert.ToInt32(ViewState["TotalPages"]);
            fistIndex = lastIndex - 5;
        }

        if (fistIndex < 0)
        {
            fistIndex = 0;
        }

        for (int i = fistIndex; i < lastIndex; i++)
        {
            DataRow dr = dt.NewRow();
            dr[0] = i;
            dr[1] = i + 1;
            dt.Rows.Add(dr);
        }

        this.dlPaging.DataSource = dt;
        this.dlPaging.DataBind();
    }
    #endregion


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.BindItemsList();
        }
    }
    protected void lbtnNext_Click(object sender, EventArgs e)
    {

        CurrentPage += 1;
        this.BindItemsList();

    }
    protected void lbtnPrevious_Click(object sender, EventArgs e)
    {
        CurrentPage -= 1;
        this.BindItemsList();

    }
    protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName.Equals("Paging"))
        {
            CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
            this.BindItemsList();
        }
    }
    protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
        if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString())
        {
            lnkbtnPage.Enabled = false;
            lnkbtnPage.Style.Add("fone-size", "14px");
            lnkbtnPage.Font.Bold = true;

        }
    }
    protected void lbtnLast_Click(object sender, EventArgs e)
    {

        CurrentPage = (Convert.ToInt32(ViewState["TotalPages"]) - 1);
        this.BindItemsList();

    }
    protected void lbtnFirst_Click(object sender, EventArgs e)
    {

        CurrentPage = 0;
        this.BindItemsList();


    }
}

Tuesday, May 13, 2014

CTS

As .Net Framework is language independent and support over 20 different programming languages, many programmers will write data types in their own programming language.

For example, an integer variable in C# is written as int, whereas in Visual Basic it is written as integer. Therefore in .Net Framework you have single class called System.Int32 to interpret these variables. Similarly, for the ArrayList data type .Net Framework has a common type called System.Collections.ArrayList. In .Net Framework, System.Object is the common base type from where all the other types are derived.
This system is called Common Type System. The types in .NET Framework are the base on which .NET applications, components, and controls are built. Common Type System in .Net Framework defines how data types are going to be declared and managed in runtime. The Common Type System performs the following functions:
• Automatically adapts itself in a framework that enables integration of multiple languages, type safety, and high performance code execution.
• Provides an object-oriented model.
• Standardizes the conventions that all the languages must follow.
• Invokes security checks.
• Encapsulates data structures.

There are two general types of categories in .Net Framework that Common Type System support. They are value types and reference types. Value types contain data and are user-defined or built-in. they are placed in a stack or in order in a structure. Reference types store a reference of the value’s memory address. They are allocated in a heap structure. You can determine the type of a reference by the values of self-describing types. Reference types can be categorized into self-describing types, pointer types, or interface types.
There are many other types that can be defined under Value types and Reference types. In .Net Framework, the System namespace is the root for all the data types. This namespace consists of classes such as Object, Byte, String, and Int32 that represents base data types. These base data types are used by all applications. During runtime a type name can be classified into two: the assembly name and the type’s name within the assembly. The runtime in .Net Framework uses assemblies to find and load types.

Dot Net Code Access Security

The .NET Security Model provides code access permissions and code identity permissions. Code Access Security is the part of the .NET security model that determines whether or not the code is allowed to run, and what resources it can use when it is running. Code Access Security policy uses evidence to help grant the right permissions to the right assembly.
An administrator can configure Code Access Security policy to restrict the resource types that code can access and the other privileged operations it can perform. Code Access Security allows code to be trusted to varying degrees depending on where the code originates and on other aspects of the code's identity. Code Access Security can also help minimize the damage that can result from security vulnerabilities in your code.

CTS

Common Type System (CTS) describes a set of types that can be used in different .Net languages in common . That is , the Common Type System (CTS) ensure that objects written in different .Net languages can interact with each other. For Communicating between programs written in any .NET complaint language, the types have to be compatible on the basic level .
These types can be Value Types or Reference Types . The Value Types are passed by values and stored in the stack. The Reference Types are passed by references and stored in the heap. Common Type System (CTS) provides base set of Data Types which is responsible for cross language integration. The Common Language Runtime (CLR) can load and execute the source code written in any .Net language, only if the type is described in the Common Type System (CTS) .Most of the members defined by types in the .NET Framework Class Library (FCL) are Common Language Specification (CLS) compliant Types.

Monday, May 12, 2014

How to call list by Josn in asp.net c#?

[WebMethod]
        public static AgencyLocation[] BindAgencyStateByserviceTest()
        {
            List<AgencyLocation> listAgencyLocationDef = new List<AgencyLocation>();          
            using (var objClient = ServiceAgentHelper.GetAgencyUserDetailContractClient())
            {
                listAgencyLocationDef = objClient.Channel.GetAgencyLocationByAgency(17, 1056706, "ALLS");
            }          
            return listAgencyLocationDef.ToArray();
        }






==============================

  <script src="../../Scripts/jquery-1.8.3.min.js" type="text/javascript" ></script>
    <script type="text/javascript">
        $(function () {         
            $.ajax({
                url: 'AgencyUserDetails.aspx/BindAgencyStateByserviceTest',
                type: 'POST',
                contentType: 'application/json; charset=utf-8',
                success: function (data) {
                    $.each(data.d, function (key, value) {
                      alert(value.Stateid);
                    });
                }
            });
        });
    </script>

Thursday, May 8, 2014

helper method in mvc4

 @helper Img(string picName, string alt ){
        string root = "/Images/";
      string imgurl = root + picName;
      <img  alt="@alt" src="@imgurl" title="@alt" />

 }
  @Img("pp.jpg","yyut")

Wednesday, May 7, 2014

Checkbox count restriction

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="WebApp.test" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<script src="Scripts/jquery-2.1.0.min.js"></script>

<script>

$(function () {

$("#pp input:checkbox").click(function () {

if ($("#pp :checked").size() > 2) {

alert('message');

this.checked = false;



}

});

});



</script>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:CheckBoxList ID="pp" AutoPostBack="true" runat="server" OnSelectedIndexChanged="pp_SelectedIndexChanged">

<asp:ListItem Text="1" Value="1"></asp:ListItem>

<asp:ListItem Text="1" Value="1"></asp:ListItem>

<asp:ListItem Text="1" Value="1"></asp:ListItem>

<asp:ListItem Text="1" Value="1"></asp:ListItem>

<asp:ListItem Text="1" Value="1"></asp:ListItem>

</asp:CheckBoxList>

</div>

</form>

</body>

</html>

Monday, May 5, 2014

how to create channel in wcf?

BasicHttpBinding myBinding = new BasicHttpBinding();

EndpointAddress myEndpoint = new EndpointAddress("http://localhost:50498/Service1.svc");

ChannelFactory<IService1> myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);

IService1 instance = myChannelFactory.CreateChannel();

string st=instance.GetData(67868);