Friday, February 11, 2011

Jquery Example Textbox Valitation







Java Script Text Box Empty Validation:-


[code]
function TextboxEmptyValidation()
{
var txt=document.getElementById("TextBox1");
if(txt.value=="")
{
alert("Textbox cannot be blank");
txt.focus();
return false;
}
}
You can call above function like this


[/code]

Tuesday, February 8, 2011

Progress Bar In Asp .Net With Ajax



protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
{
Label1.Text = DateTime.Now.ToLongTimeString();
Label2.Text = DateTime.Now.ToLongTimeString();
}
}
The Progress Bar Button Click then Progress bar is Working as You see Image
protected void ProgressBarButton_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label2.Text = DateTime.Now.ToLongTimeString();
}

Friday, January 28, 2011

Add Parent and Child Node In TreeView In C#

private void ViewAllRoom_Load(object sender, EventArgs e)
{
//This Is Parent Node
TreeNode MainNode = new TreeNode();
MainNode.NodeFont = new Font("Microsoft Sans Serif", 10);
MainNode.Name = "MainName";
MainNode.Text = "All Rooms";
MainNode.ForeColor = Color.Red;
this.treeView1.Nodes.Add(MainNode);

//Next add child Node
ds = da.GetDataTable("SELECT RName FROM RTypeCreation");
foreach (DataRow Parentrow in ds.Tables[0].Rows)
{
TreeNode treenode = new TreeNode((string)Parentrow["RName"]);
MainNode.Nodes.Add(treenode);
treenode.NodeFont = new Font("Microsoft Sans Serif", 10);
treenode.ForeColor = Color.Tan;
}

Monday, January 17, 2011

Create Button at Run Time In C #

for (int i = 0; i < 10; i++)
{
obj = new Button();
obj.Location = new Point(bt, 80);
newname = (btn + i).ToString();
obj.Name = "Table";
obj.Text = newname;
obj.Height = 50;
obj.Width = 80;
obj.Click += new EventHandler(obj_Click);
this.Controls.Add(obj);
bt += 90;
}

Run Time Created Button Color Change In C#

public void BtnColourChg()
{
DataAccess da = new DataAccess();
try
{
da.OpenConnection();
SqlDataReader dr = da.ExecuteReader("Select tableno from billtotal where status=1");
while (dr.Read())
{
foreach (Control item in this.Controls)
{
if (item is Button)
{
Button b = (Button)item;
if (b.Text == dr[0].ToString())
{
b.BackColor = System.Drawing.Color.Red;
}
}
}
}
}
catch (Exception ex) { }
finally { da.CloseConnection(); }
}