Compilation Error - "CS1513: } expected"
-
Hi, I always get this error when i use events for controls in aspx, events like onClick(), checkedChanged(), .. If I remove that event from aspx the error disappears, pls find the error details below. I tried giving semi-colon after the function name like: OnClick="NumericOnly_onkeypress(event);" still i get this error. Has anyone come across this error? Reagrds, Blumen
-
Hi, I always get this error when i use events for controls in aspx, events like onClick(), checkedChanged(), .. If I remove that event from aspx the error disappears, pls find the error details below. I tried giving semi-colon after the function name like: OnClick="NumericOnly_onkeypress(event);" still i get this error. Has anyone come across this error? Reagrds, Blumen
HI Blumen, I am not sure but try like this..
Kiran Kumar.CH (MCP)
-
HI Blumen, I am not sure but try like this..
Kiran Kumar.CH (MCP)
-
Hi, I always get this error when i use events for controls in aspx, events like onClick(), checkedChanged(), .. If I remove that event from aspx the error disappears, pls find the error details below. I tried giving semi-colon after the function name like: OnClick="NumericOnly_onkeypress(event);" still i get this error. Has anyone come across this error? Reagrds, Blumen
Make sure that autoeventwireup at page attribute is turned off i.e make it false if you are using IDE. Make sure that "NumericOnly_onkeypress" event handler has correct arguments i.e void NumericOnly_onkeypress(sender as object,e as EventArgs) { } Tell me where you are writing this handler either in code behind i.e .cs file are inpage i.e in aspx file?
Kiran Kumar.CH (MCP)
-
Make sure that autoeventwireup at page attribute is turned off i.e make it false if you are using IDE. Make sure that "NumericOnly_onkeypress" event handler has correct arguments i.e void NumericOnly_onkeypress(sender as object,e as EventArgs) { } Tell me where you are writing this handler either in code behind i.e .cs file are inpage i.e in aspx file?
Kiran Kumar.CH (MCP)
kiran kumar[Intelligroup] wrote:
Make sure that autoeventwireup at page attribute is turned off
It was turned off already, still same error
kiran kumar[Intelligroup] wrote:
Tell me where you are writing this handler
in aspx This is the function: function NumericOnly_onkeypress() { if(window.event.keyCode<48 || window.event.keyCode>57 ) { window.event.keyCode=false; return false; } } Regards, Blumen
-
kiran kumar[Intelligroup] wrote:
Make sure that autoeventwireup at page attribute is turned off
It was turned off already, still same error
kiran kumar[Intelligroup] wrote:
Tell me where you are writing this handler
in aspx This is the function: function NumericOnly_onkeypress() { if(window.event.keyCode<48 || window.event.keyCode>57 ) { window.event.keyCode=false; return false; } } Regards, Blumen
if you are using asp.net 1.1 do this way remove onclick="NumericOnly_onkeypress" in aspx file and write the statement like this in .cs file page load event buttion1.attributes.add("onclick","NumericOnly_onkeypress"); if you are using asp.net 2.0 you can write like this Text="Button" önClientClick="NumericOnly_onkeypress">
Kiran Kumar.CH (MCP)
-
if you are using asp.net 1.1 do this way remove onclick="NumericOnly_onkeypress" in aspx file and write the statement like this in .cs file page load event buttion1.attributes.add("onclick","NumericOnly_onkeypress"); if you are using asp.net 2.0 you can write like this Text="Button" önClientClick="NumericOnly_onkeypress">
Kiran Kumar.CH (MCP)
Thanks Kiran, that did the trick for TextBox keypress event, but for Radiobutton and CheckBox, the function in aspx is not firing: I gave it like this: rbn1.Attributes.Add("OnCheckedChanged", "Onkeypress(this)"); rbn2.Attributes.Add("OnCheckedChanged", "Onkeypress(this)"); function Onkeypress(thiss) { if (document.getElementById (thiss.id).checked == true) alert("checked"); } Why does it work when I hook the event handler as an attribute? And why doesn't it work for RadioButton and CheckBox? Regards, Blumen
-
Thanks Kiran, that did the trick for TextBox keypress event, but for Radiobutton and CheckBox, the function in aspx is not firing: I gave it like this: rbn1.Attributes.Add("OnCheckedChanged", "Onkeypress(this)"); rbn2.Attributes.Add("OnCheckedChanged", "Onkeypress(this)"); function Onkeypress(thiss) { if (document.getElementById (thiss.id).checked == true) alert("checked"); } Why does it work when I hook the event handler as an attribute? And why doesn't it work for RadioButton and CheckBox? Regards, Blumen
Now it will work because OnCheckedChange is serverside event.but your function is at client side naa so write like this rbn1.Attributes.Add("onclick", "Onkeypress(this)"); rbn2.Attributes.Add("onclick", "Onkeypress(this)");
Kiran Kumar.CH (MCP)
-
kiran kumar[Intelligroup] wrote:
Make sure that autoeventwireup at page attribute is turned off
It was turned off already, still same error
kiran kumar[Intelligroup] wrote:
Tell me where you are writing this handler
in aspx This is the function: function NumericOnly_onkeypress() { if(window.event.keyCode<48 || window.event.keyCode>57 ) { window.event.keyCode=false; return false; } } Regards, Blumen
You are getting the server-side and client-side events mixed up. For an OnClick is the server side event (and expects a function name that is in your code behind) and OnClientClick is where you can put client-side javascript calls (this attribute simply expects a string). Have a look at the MSDN documentation for more.
-
You are getting the server-side and client-side events mixed up. For an OnClick is the server side event (and expects a function name that is in your code behind) and OnClientClick is where you can put client-side javascript calls (this attribute simply expects a string). Have a look at the MSDN documentation for more.