C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




CheckBox Check


Posted Date: 30 Jun 2008      Total Responses: 2

Posted By: Sanjeev Kumar       Member Level: Gold     Points: 1



Hi, I've a Gridview n a checkbox column inside it like a header template n item template. All serverside asp.net controls.I want to do when I check the header Checkbox all checkbox shud be checked n wen unchecked it shud be unchecked. I know how to do with server side codes bt I want to do it through JavaScript means client side. Plz write code if u've.
Thanks.
Previous ans was for client side control. so sorry. I've to use asp.net controls.





Responses

Author: yathika     30 Jun 2008Member Level: GoldRating:     Points: 6

Try this:
----------

<HeaderTemplate>
<input type="checkbox" name="SelectAllChkbox" onclick="SelectAll(this)"/>All
</HeaderTemplate>


Script
-------
function SelectAll(CheckBoxControl)
{
if (CheckBoxControl.checked == true)
{
var i;
for (i=0; i < document.forms[0].elements.length; i++)
{
if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('gridview1') > -1))
{
document.forms[0].elements[i].checked = true;
}
}
}
else
{
var i;
for (i=0; i < document.forms[0].elements.length; i++)
{
if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('gridview1') > -1))
{
document.forms[0].elements[i].checked = false;
}
}
}
}
}
}



Author: Sanjeev Kumar    30 Jun 2008Member Level: GoldRating:     Points: 0

Hi,Thanks alot its working good.
Thanks.



Post Reply
You must Sign In to post a response.
Next : JAVA SCRIPT
Previous : please help me ....its urgent...
Return to Discussion Forum
Post New Message
Category: JavaScript

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use