Link to home
Start Free TrialLog in
Avatar of Programmer_to_be
Programmer_to_be

asked on

Inline code event handlers

Hello Experts

I am using Visual Studio.NET 2005 for ASP.NET (C#) development. Whenever I double click a control that I drag onto my webform (from the toolbox) it generates the default event handler in the code behind. Is there any way to get the event handler to appear inline with the HTML source (in a <script> tag) rather than the code behind by default?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of dstanley9
dstanley9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Programmer_to_be
Programmer_to_be

ASKER

Hi dstanley9, yes I'm refering to a server side script block not client side. I am in the process of learning web development and came across the concept of "inline code" organisation and "code behind" organisation. I briefly know the pros and cons associated with each approach (i.e. code behind seperates concerns etc), and just wanted to know if it was possible to automatically generate an event handler method in a script block rather than the code behind (in VS.NET 2005).

Are you therefore saying that I'll have to copy the event handler across from the code behind to the html source in a script block?

Thanks for your help
Yes that is correct.  One other "disadvantage" is that the method does not show up in the drop-down listts in the properties window as a valid event handler.  However, VS is smart enough to take you to the inline code when you double-click the control _after_ you have copied and pasted the code.