Create Own new event Handlers ASP.Net
-
-
Hi, I have to add new event handler for my custom control.how to create own event to my control.Like Click ,Mouseover events .Please help me anybody. Thanks Srini DSR Software Engineer Kualalumpur Malaysia. Phone# 601-769-20477 Office #603-228-40073
-
Hi, I have to add new event handler for my custom control.how to create own event to my control.Like Click ,Mouseover events .Please help me anybody. Thanks Srini DSR Software Engineer Kualalumpur Malaysia. Phone# 601-769-20477 Office #603-228-40073
Web pages consist of two parts. There is a part on the client in (D)(X)HTML, and there is a part on the server (the ASP.NET page and codebehind). Anything that happens in the ASP.NET code behind (or inline server side elements, such as <% %>) requires a post back. Post backs are slow (it's like if you typed a new address and hit enter, it has to go talk to the server), so you don't want to generate them if you can avoid it. So it's very likely what you are wanting to do needs CSS2, DHTML and/or JavaScript. If you go and do a search in Google for DHTML and JavaScript, you'll find some starting points. CodeProject has some nice articles. You can register a block of client script with the RegisterClientScriptBlock method of the Page object. This creates a block of script with a unique identifier identifying it, so if it's called for the same script a few times, you only get one copy of the code. You can register a post-back event handler using Page.GetPostBackEventReference. It creates the necessary code, and returns a string containing the code to cause a post back to the server. In some cases, the string it returns might not be what you want, you might want to generate other code (it posts back a single string parameter -- if that's not what you want, you have to write JavaScript to get what you want into the parameter). The events you can hook are determined by the specific client browser and the element you are placing a hook on. You need to look at a DHTML reference to see what events are available, and what they are named. Note if you need to run on non-Microsoft browsers, you'll need to look up what events are common, and what they are named. Standards compliant browsers sometimes use different names from Microsoft's, and sometimes require different code from Microsoft's. Typically, the code will look something like this: You can do this either from code behind or from the ASP.NET page itself, depending on if you need to dynamically generate the JavaScript or not. Additionally, on standards compliant browsers (or on IE 6 with ie7.sf.net loaded), for many effects, you don't need to use JavaScript at all. Using CSS2, you can implement mouse overs where a graphic changes, for example. The benefit to using CSS2 is that it is a standard, and supported natively by the browser, so you have less maintenence.
-
Web pages consist of two parts. There is a part on the client in (D)(X)HTML, and there is a part on the server (the ASP.NET page and codebehind). Anything that happens in the ASP.NET code behind (or inline server side elements, such as <% %>) requires a post back. Post backs are slow (it's like if you typed a new address and hit enter, it has to go talk to the server), so you don't want to generate them if you can avoid it. So it's very likely what you are wanting to do needs CSS2, DHTML and/or JavaScript. If you go and do a search in Google for DHTML and JavaScript, you'll find some starting points. CodeProject has some nice articles. You can register a block of client script with the RegisterClientScriptBlock method of the Page object. This creates a block of script with a unique identifier identifying it, so if it's called for the same script a few times, you only get one copy of the code. You can register a post-back event handler using Page.GetPostBackEventReference. It creates the necessary code, and returns a string containing the code to cause a post back to the server. In some cases, the string it returns might not be what you want, you might want to generate other code (it posts back a single string parameter -- if that's not what you want, you have to write JavaScript to get what you want into the parameter). The events you can hook are determined by the specific client browser and the element you are placing a hook on. You need to look at a DHTML reference to see what events are available, and what they are named. Note if you need to run on non-Microsoft browsers, you'll need to look up what events are common, and what they are named. Standards compliant browsers sometimes use different names from Microsoft's, and sometimes require different code from Microsoft's. Typically, the code will look something like this: You can do this either from code behind or from the ASP.NET page itself, depending on if you need to dynamically generate the JavaScript or not. Additionally, on standards compliant browsers (or on IE 6 with ie7.sf.net loaded), for many effects, you don't need to use JavaScript at all. Using CSS2, you can implement mouse overs where a graphic changes, for example. The benefit to using CSS2 is that it is a standard, and supported natively by the browser, so you have less maintenence.
Thank you.. Actually i want implement charts like Bar,Pie in my current project.I got blong.dll and source code from Codeproject article: http://www.codeproject.com/aspnet/webchart.asp" .If user clicks particualr dimension i want fire events based on the value. Please let me know ASAP. Thanks & Regards Rao