Google Custom Search

Posted by Venkat | Labels: , ,

Google Custome Search

Google provider Custom search - that can be integrated to our own site - to searh a text,keywords
inside our site.

This is the link go Through and add to your site.

http://code.google.com/apis/customsearch/docs/ui.html

Fetch DB to Xml then bind to Asp.net Server control

Posted by Venkat | Labels: , ,

Today I am going to see how to bind or get the Data from the DB to XML file. so XML is also a
Datasource to store the data or content and you can get the data from xml file easily,it also
improves server performance. ie: instead of creating connection and request the DB to fetch the data
, Getting the Data , Closing Connection. so this operation occurs multiple times or as per
user needs.

Now what i am doing here is , first get the Table Data From DB to the XML file.
first i had created one xml file called Test.xml - to place the Employee Tables Data.

Then OnButton_Click Event i have written the code to bind the data to XML file.

Ex: i am getting the Employee Table from DB bind to the XML file.

Here is the Code :

Include Namespace

using System.IO;
using System.Data.SqlClient;


protected void Button1_Click(object sender, EventArgs e)
    {
        SqlCommand command = new SqlCommand();
        command.CommandText = "Select * from Employees";
        command.CommandType = CommandType.Text;
        command.Connection = con;
        SqlDataAdapter da = new SqlDataAdapter(command);
        DataSet ds = new DataSet();
        da.Fill(ds, "Emp");
       
        // Get a StreamWriter object
        StreamWriter xmlDoc = new StreamWriter(Server.MapPath("~/Test.xml"), false);

        // Apply the WriteXml method to write an XML document
        ds.WriteXml(xmlDoc, XmlWriteMode .WriteSchema );
        xmlDoc.Close();

       
    }
After that - i am going to bind the all the employeename and empid to the Dropdownlist.

Here is the Code : so we get the emp details on the XML file , we have to retrieve the data
from the XML file using Dataset because - Dataset has two method ReadXML and WriteXML ie: able
to read or write the data from the XML.

so after read the data from XML to Dataset, now we have all the emp details on the Dataset ds,
. just bind as its to the Dropdownlist datasource.


 DataSet ds = new DataSet();

 ds.ReadXml(Server.MapPath("~/Testdo.xml"));

DropDownlist1.DataSource = ds;
DropDownlist1.DataTextField = "empname";
DropDownlist1.DataValueField = "empid";
DropDownlist1.DataBind();
suppose i want to filter the employees whose salary is greater than 20000

write like this

dt = ds.Tables[0];
  DataRow[] dr ;
        dr = dt.Select("salary >= '20000'");

 DataTable fDt = new DataTable();
        fDt.Columns.Add("empName");
        fDt.Columns.Add("empId");

 foreach (DataRow dr1 in dr)
        {
            DataRow newrow = fDt.NewRow(); 
            newrow[0] = dr1[0];  // here you have to give correct index for the empid or empname field name
            newrow[1] = dr1[1];
           

            fDt.Rows.Add(newrow);
        }

dropdownlist2.DataSource = fDt;
DropDownlist1.DataTextField = "empname";
DropDownlist1.DataValueField = "empid";
DropDownlist1.DataBind();

Creation Tooltip

Posted by Venkat | Labels: , ,

Good Friday to all.

Now i am going to show how to create  a Tooltip using Javascript there are many scripts,JQuery available to make the work easy and even we can design the tooltip stylish manner.

But finally i have worked with this sample , it shows tooltip , when u click on the Textbox - you can give your own font color, backcolor.

Here is the link Check it

http://lixlpixel.org/javascript-tooltips/

And its a dynamic tool tip..

http://blog.devarchive.net/2008/04/advanced-tooltip-control-aspnet-ajax.html

Here is the Screenshot

How to Create Nifty Round corner

Posted by Venkat | Labels: , ,

I have situation Create a Roundcorner for the table or div or panel ...
So in Ajax there is a built-in-control - RoundCornerExtender is available , but i have used that but i was not showing the round corner sometimes properly.

so i found this Nifty round corner was the good one, no image needed for the Round Corner.

Its full javascript., you can apply the round corner to div,panel,table etc..

Here is the Sample code

First you have to add Javascript on your page. You can get the javascript here ie: niftycube.js and niftycorner.css.

http://www.html.it/articoli/nifty/index.html

http://www.html.it/articoli/niftycube/index.html

You have to write code like this

if you use id use (#) , if you are going to use it for class user (.)


<script type="text/javascript">
window.onload=function(){
Nifty("div#box","big");
Nifty("Panel#" + '<%= contactUs_Panel.ClientID %>',"transparent");
Nifty("Panel.setround","big");
Nifty("Panel#" + '<%= callback_Panel.ClientID %>',"transparent");
Nifty("table.setround","big");

//Nifty("PopupControlExtender","big");
}
</script>


Validate Indian Mobile Number

Posted by Venkat | Labels: ,

Hi , Now i am going to discuss about how to validate a Indian Mobile Number.

First the Mobile Number field should not be null so for that - Add RequiredFieldValidator.

It should not accept any Aplhabets , or any special characters for this you have to write RegularExpression Validator to Accept only Numbers
EX:

Regex \d+


Atlast i have to check whether user entered Number is 10 digit or not and also it should be valid Mobile Number
Regex ^[9][0-9]{9}$


This Regex which first digit should be 9 then followed by 9 digits and totally it accept only 10 digits.

PayOffers.in