Client-side JavaScript code and ASP.NET controls

  • Thread starter Thread starter Leszek
  • Start date Start date
L

Leszek

Hello,

Is there any possibility using ASP.NET and Visual Studio.NET to create
controls that response for simple JavaScript events such as OnClick and
OnSelect? For example I need to change the color of a table cell when a
certain button is selected. In this case there is no need to do a round-trip
to the web server. I need to assign an event handler to the button's OnClick
event. Does the VS.NET support this kind of events?

Thanks for any suggestions,
Leszek Taratuta
 
It's the same with ASP.NET as it is with standard HTML - just add the
onclick property to the markup of an input type=button. If you are using an
asp:button (and I'm not sure why you would be, if you don't want the server
to handle it, what is the point) then it actually does add an onclick
attribute already, so this can lead to conflicts that some people have seen.
If you need to dynamically insert script, just set runat=server and then use
button.Attributes.Add to attach a script (or set any other attribute, for
that matter).
 
Thanks for your reply!
Do you know where I can find a sample code to create such a control?

Leszek Taratuta
 
Hi Leszek,

Based on my research, there is not an existed sample code in Microsoft Web
Site. If you need sample code, I suggest you try Microsoft Advisory
Service option. More detailed information regarding Microsoft Advisory
Service can be found at the following link:

http://support.microsoft.com/common/international.aspx?rdpath=fh;en-us;advis
oryservice

Best regards,

Jacob Yang
Microsoft Online Partner Support
<MCSD>
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thanks for your reply.
I'll try to find such a control somewhere else, and then try the Microsoft
Advisory Service.

Thanks,
Leszek Taratuta
 
Back
Top