Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

do you know what could be wrong with this code?
<asp:CheckBox runat="server" ID="chbMajorIncidentSelection"  OnCheckedChanged="javascript:OnCheckedChanged();"/>


I'm getting an error: CS1026: ) expected.

I would say that this should work, that function OnCheckedChanged is defined in javascript, on the same control as the checkbox.
Posted
Comments
Dhanamanikandan 12-Apr-12 9:17am    
Hi,
Please post your javascript code as well. I guess you have missed ')' in your JS Code. On the OncheckedChanged property you can define like this 'OnCheckedChanged();'

Hi

oncheckedchanged is server side event so you can't redirect to javascript


change that event to

ASP.NET
<asp:checkbox id="CheckBox1" runat="server" onchange="javascript:OnCheckedChanged();" xmlns:asp="#unknown" />



All the Best
 
Share this answer
 
Comments
Petra Cerna 12-Apr-12 9:42am    
I have tried it but the error is still the same. What does it mean xmlns:asp="#unknown" ? What it should do?
Muralikrishna8811 12-Apr-12 9:47am    
xmlns="#unknown" is nothing its just added by code project parser

event should be "onchange" not "oncheckedchanged"

still u r getting error means u've problem with body of that method
Is OnCheckedChanged a javascript event or a code-behind event? I've never seen a javascript call on a code-behind event, so this might be the problem.

in additon use OnCheckedChanged(); instead of javascript:OnCheckedChanged();

PS: eg. on a asp:button control you have an onclick event (server) and an onclientclick event (client). The first one calls the code-behind, the second the javascript code. For Checkbox this is probably the "checked" event or something similar.


hope this helps.
 
Share this answer
 
Comments
Petra Cerna 12-Apr-12 9:43am    
I have tried to use it as you wrote but the error is staying the same.
V. 12-Apr-12 9:54am    
do you have more code? (javascript function eg.) Comment everything in that function out and replace by "alert('test');" Now an alert box should appear. Then you at least know the call is correct and you jump into the function. You can work from there to find the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900