CS1026 error

  • Thread starter Thread starter jib
  • Start date Start date
J

jib

I am trying to set up a OnLoad javascript for a Textbox using the following
script:

<asp:TextBox id="Tbx_AssignedTo" runat="server" Width="184px"
OnLoad="javascript:doTypeSelect(document.activeElement.id)">
</asp:TextBox>

However, this gives me a "CS1026: ) expected" error. I haven't got the
foggiest as to what this means. Can anyone shed some light on this?

Thanks!

Jib
 
Remember that you have a different syntax for a web control element than you
do for an HTML element. In order to render the HTML "onload='...'" you need
to use Tbx_AssignedTo.Attributes.Add("onload", "..."). The TextBox is an
object that is processed on the server. OnLoad is a method of that object
which invokes some action on the server, and isn't just rendered to the
client as you type it. Your ASPX code is declaratively writing code that the
server generates and compiles - it's a lot more than authoring a DHTML page.
If you don't need the features of a textbox, you can also use <input
type="text" runat="server" ... /> and spare the more verbose syntax needed
to render client side behavior.
 
Back
Top