This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Tuesday, November 17, 2015

jQuery UI AutoComplete TextBox with asp.net webforms



Method 1 (using Handlers)


Connection String
<connectionStrings>
      <addname="constr"connectionString="Data Source = .\SQLExpress;       
       Initial Catalog = Northwind; Integrated Security = true"/>
</connectionStrings>

  
AutoComplete Handler
<%@ WebHandler Language="C#" Class="Search_CS" %>
using System;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
public class Search_CS : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        string prefixText = context.Request.QueryString["q"];
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = ConfigurationManager
                    .ConnectionStrings["constr"].ConnectionString;
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "select ContactName from Customers where " +
                "ContactName like @SearchText + '%'";
                cmd.Parameters.AddWithValue("@SearchText", prefixText);
                cmd.Connection = conn;
                StringBuilder sb = new StringBuilder();
                conn.Open();
                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        sb.Append(sdr["ContactName"])
                            .Append(Environment.NewLine);
                    }
                }
                conn.Close();
                context.Response.Write(sb.ToString());
            }
        }
    }
    public bool IsReusable {
        get {
            return false;
        }
    }
}

Client Side Implementation
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
<link href="css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<script src="scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="scripts/jquery.autocomplete.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("#<%=txtSearch.ClientID%>").autocomplete('Search_CS.ashx');
    });      
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>

Javascript
<script type="text/javascript">
    $(document).ready(function() {
        $("#<TextBoxControlId>").autocomplete('<Url of handler>');
    });      
</script>
Example AJAX Autocomplete Extender using jQuery in ASP.Net



Method 2 (using web Methods)


Aspx page
protected void Page_Load(object sender, EventArgs e)
{

}

[WebMethod]
public static List<string> GetAutoCompleteData(string username)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=SureshDasari;Integrated Security=true;Initial Catalog=MySampleDB"))
{
using (SqlCommand cmd = new SqlCommand("select DISTINCT UserName from UserInformation where UserName LIKE '%'+@SearchText+'%'", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", username);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(dr["UserName"].ToString());
}
return result;
}
}
}


Javascript in Head section of the page 
 
$(".autosuggest").autocomplete({
source: function(request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/GetAutoCompleteData",
data: "{'username':'" + document.getElementById('txtSearch').value + "'}",
dataType: "json",
success: function(data) {
response(data.d);
},
error: function(result) {
alert("Error");
}
});
}
});


Tuesday, November 3, 2015

Earn





Start earning money in less than 10 minutes!


Maximize your revenue with PopCash! You can start earning money in less then 10 minutes. All you need is an account in our system and your domains approved. Once you have done those things you can place the Javascript code (generated by our system) in your website body. This is all! Now all your visitors will view a pop-under from PopCash. Our pop-under is showed once in a 24 hour timeframe, so your visitors will not be disturbed by repeated popunders!

Key Advantages


  • Almost all websites are accepted.
  • We pay for all visitors (worldwide traffic).
  • Clean ads. We test the campaigns landing pages multiple times every day.
  • Withdrawals are processed daily (on weekdays).
  • Minimum withdrawal amount is only $10.
  • Very quick domain approval.
  • Hourly updated detailed statistics of your revenues.
  • Intuitive and very easy to use administration interface.
  • Online support through many instant messengers and through email.
  • Many targeting & optimizing possibilities and various traffic sources.
  • Payments through PayPal, Paxum or Payza.

Are you ready to start? You can register here!

Friday, October 31, 2014

Dynamic DataTable

                     DataSet ds = new DataSet();
            DataTable dtEmp = new DataTable();
            DataTable dtDept = new DataTable();

            DataColumn deptPK = new DataColumn { ColumnName = "DepartmentID", DataType = typeof(Int32), AutoIncrement = true };
            dtDept.Columns.Add(deptPK);
            dtDept.Columns.Add(new DataColumn { ColumnName = "DeptName", DataType = typeof(string) });
            dtDept.PrimaryKey = new DataColumn[] { deptPK };
            ds.Tables.Add(dtDept);

            DataColumn empPK = new DataColumn { ColumnName = "EmpID", DataType = typeof(Int32), AutoIncrement = true };
            DataColumn colName = new DataColumn { ColumnName = "Name", DataType = typeof(string), AutoIncrement = true };
            dtEmp.Columns.Add(empPK);
            dtEmp.Columns.Add(colName);
            dtEmp.Columns.Add(new DataColumn { ColumnName = "City", DataType = typeof(string), AutoIncrement = true });
            dtEmp.Columns.Add(new DataColumn { ColumnName = "Salary", DataType = typeof(double), AutoIncrement = true });
            dtEmp.Columns.Add(new DataColumn { ColumnName = "DOJ", DataType = typeof(DateTime), AutoIncrement = true });
            dtEmp.Columns.Add(new DataColumn { ColumnName = "DepartmentID", DataType = typeof(Int32), AutoIncrement = true });
            //Constraints
            dtEmp.PrimaryKey = new DataColumn[] { empPK };
            UniqueConstraint unq = new UniqueConstraint(new DataColumn[] { colName });
            dtEmp.Constraints.Add(unq);
            ds.Tables.Add(dtEmp);


            ForeignKeyConstraint fk = new ForeignKeyConstraint("ForeignKey", dtDept.Columns["DepartmentID"], dtEmp.Columns["DepartmentID"]);
            dtEmp.Constraints.Add(fk);




Thursday, September 4, 2014

Events

Events Description
onBlur Code is executed when the focus is removed from the text field.
onChange Code is executed when the user changes the value within the text field, and removes focus away from the field.
onFocus Code is executed when the focus is set on the text field.
onKeyDown Code is executed when user presses down the key within the text field.
onKeyPress Code is executed when user presses the key within the text field.
onKeyUp Code is executed when user releases a key within the text field.
onSelect Code is executed when user selects some text within the text field.

Properties

Properties Description
accessKey String value that sets/ returns the accessKey for the field.
disabled Boolean value that sets/ returns whether the field is disabled.
form References the form that contains the text field.
name Reflects the name of the text field (the name attribute).
type A property available on all form elements, "type" returns the type of the calling form element, in this case, "text".
value Read/write string that specifies the value of the text field.

Methods

Methods Description
blur() Removes focus away from the text field.
focus() Sets focus on the text field.
select() Highlights the content of the text field.

Table td click event using jQuery

jQuery
$(document).ready(function () {

            $("#mytable td").click(function () {
                alert($(this).html());
                alert($(this).attr('class'));               
            });           

        });

HTML:
<table id="mytable" style="width: 100%;">

        <tr>
            <td class="s">Row11</td>
            <td>Row12</td>
            <td>Row13</td>
        </tr>
        <tr>
            <td>Row21</td>
            <td>Row22</td>
            <td>Row23</td>
        </tr>
        <tr>
            <td>Row31</td>
            <td>Row32</td>
            <td>Row33</td>
        </tr>
    </table>