Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function not found ?? Compilation Error

Status
Not open for further replies.

need2progm

Programmer
Dec 13, 2002
92
US
I have a check box ....
<asp:checkbox id=&quot;chkAll&quot; OnCheckedChanged=ValueChanged() </asp:checkbox>

in script tags a I have..
<script language=&quot;javascript&quot;>

function ValueChanged()
{
//check all was selected so check all the parents
// selecting the parents will recursivly check/uncheck its children

var grid = igtbl_getGridById(tableName); //get grid
var gridRows = grid.Rows; // returns all the rows in band 0
var checkAllValue = document.getElementByID
('chkAll').Checked;

if(gridRows == null)
{} // No rows so Do NOTHING
else
{
for(i=0;i<gridRows.length;i++)
{
var Row = gridRows.getRow(i);
Row.getCell(0).setValue(value); //set value to chkAll value
}
}
return;
}

I am getting an error 'ValueChanged' is not a member of 'ASP.CreateGrid_ascx'

Does anyone have any suggeations on what I should look at?

Thanks in advance for taking time to help me out!
 
based on your error, the compiler is expecting a method called ValueChanged to be defined in the code behind file - not a javascript function. the only way to explicitly assign an event handler using attribute tags is to use html controls, and not server controls. the code behind event handlers are *typically* assigned in the inherited class' onInit()or page_init() handler.

however, there are a few clever ways to call javascript in lieu of code defined for a server control. Microsoft has an example of server controls emitting javascript code at:


for the simple, dumbed-down version, you can define your server control as such:
Code:
chkAll.Attributes.Add(&quot;onClick&quot;, &quot;ValueChanged&quot;);

this will place the two strings as html text in the attributes portion of html returned to the browser, but problems may arise if you have this control nested in collections.

..:: mirirom ::..
 
You are correct.. this works great!
chkAll.Attributes.Add(&quot;onClick&quot;, &quot;ValueChanged&quot;);

I did however have to change how I was getting the value of the check bix. I assume beacuse it is on a user control that is on a webform.

changed to this..
var checkAllValue = window.document.activeElement.checked;


Thanks for helping .. Have a great day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top