Passing arguments to java script function and receiving the return value in code behind file C#

Posted by .Netlearner under ASP.NET on 12/19/2012 | Points: 10 | Views : 1052 | Status : [Member] | Replies : 2
Hello All,
I Have a scenario where i want to send color name as the argument to the javascript function .

The Java Script Function Returns th Color Code for that Particular Color Name.

Am wondering how to pass argument to the javascript function and how to assign the return value in a string variable.

Can anyone please guide me.

It will be more helpfull if Any Example code is available.

Thanks In Advance




Responses

Posted by: Pavanandey on: 12/20/2012 [Member] Bronze | Points: 25

Up
0
Down
function SelectAll(id)
{
var frm = document.getElementById("<%=GvDepartments.ClientID %>");
for (i=0;i<frm.rows.length;i++)
{
cell = frm.rows[i].cells[0];
//loop according to the number of childNodes in the cell
for (j=0; j<cell.childNodes.length; j++)
{
//if childNode type is CheckBox
if (cell.childNodes[j].type =="checkbox")
{
//assign the status of the Select All checkbox to the cell checkbox within the grid
cell.childNodes[j].checked = document.getElementById(id).checked;
}
}
}
}

protected void GvDepartments_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
((CheckBox)e.Row.FindControl("cbSelectAll")).Attributes.Add("onclick", "javascript:SelectAll('" + ((CheckBox)e.Row.FindControl("cbSelectAll")).ClientID + "')");
}
}

Thanks
Pavan Kumar
Mark Answer if this fits the need

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Mark if this helps you

Thanks
Pavan Kumar
Mark Answer if this fits the need

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response