Client-side JavaScript code and ASP.NET controls

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
 
C

Chris Jackson

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).
 
L

Leszek

Thanks for your reply!
Do you know where I can find a sample code to create such a control?

Leszek Taratuta
 
J

Jacob Yang [MSFT]

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.
 
L

Leszek

Thanks for your reply.
I'll try to find such a control somewhere else, and then try the Microsoft
Advisory Service.

Thanks,
Leszek Taratuta
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top