Tuesday, August 11, 2009

Select All Checkbox on Click of One checkbox in Javascript

==Script in Javascript===
function SelectAllCheckboxes(spanChk)
{
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox= (spanChk.type=="checkbox") ?
spanChk : spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;

for(i=0;iif(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
{
if(elm[i].checked!=xState)
elm[i].click();
}
}

==Check all checkbox on selection of A Checkbox
input id="Checkbox2" type="checkbox" onclick="javascript:SelectAllCheckboxes(this);" / Check All

Clear the Controls Data on Click of Reset Button

I have 20 controls on my web page. I want to clear the controls data when onclick of reset button:
private void ClearControls(Control parent)
{
foreach (Control _ChildControl in parent.Controls)
{
if ((_ChildControl.Controls.Count > 0))
{
ClearControls(_ChildControl);
}
else
{
if (_ChildControl is TextBox)
{
((TextBox)_ChildControl).Text = string.Empty;
}
else
if (_ChildControl is CheckBox)
{
((CheckBox)_ChildControl).Checked = false;
}
else
if (_ChildControl is DropDownList)
{
((DropDownList)_ChildControl).SelectedIndex = 0;
}
else
if (_ChildControl is ListBox)
{
((ListBox)_ChildControl).SelectedIndex = 0;
}
}
}
}


calling this function like this:pn click of reset button
ClearControls(this.Page);

Monday, August 10, 2009

C# Conditions in 2 different ways

Checking condition in 2 different way

One Way is
if (item.Text.ToString() == "Professional")
query1 = "P";
else
query1 = "C";

--------
query1 = item.Text.ToString() == "Professional" ? "P" : "C";

================Separate
if (item.Selected == true)
query1 = item.Text.ToString() == "Professional" ? "P" : "C";
---------
if (item.Selected != true) continue;
query1 = item.Text.ToString() == "Professional" ? "P" : "C";

Tuesday, August 4, 2009

Referencing Blogs

http://7explications.wordpress.com/
http://sajithpremachandran.blogspot.com/
http://sajithpremachandran.wordpress.com/
http://sairamjvh.blogspot.com/
http://arrao4u.wordpress.com/
http://aspdotnetcodebook.blogspot.com/

Complete basic Tutorial of WCF