I need to add the OnClick event to asp:DropDownList control, due to the existing events don't satisfy my current needs.
Is it possible to achieve this?
Thank you very much.
What reason do you have for wanting an OnClick event on the DropDownList control? If you were to implement an OnClick server-side event on the DropDownList the user would never be able to select any of the list items. This is because in order to fire a Server-Side OnClick, a postback would be required. I.e. the user would click the DropDownList, a postback would instantly occur and they wouldn't be able to select a value.
It sounds like a case of trying to fix the wrong problem, however you could probably try and use the "onclick" JavaScript attribute and handle whatever you're trying to do using client side script and AJAX?
Related
I have a ASP.Net(C#) page. When a user selects a value in dropdownlist, some new controls will be visible to him.
I am able to that now, but the page has to reload every time and state has to be maintained between postbacks.
Is there any way to do the same without reloading of the page in a easiest way possible without using ajax control toolkit?
Additional info: the data for the dropdownlist is coming from the database, and some places it has to be all server side so i can't use javascript .
You can try this idea: http://msdn.microsoft.com/en-us/library/ms178208(v=vs.100).aspx. I have not try it before but it seems logical.
you should go through updatepanel. Put all the controls inside a updatepanel which you want to show on selectedindexchanged event of the dropdownlist and write code behind on selectedindexchanged event of the dropdownlist accordingly. Hope this will help you...
I'm a rookie in .net. I'm using an AjaxToolKit Accordion Control and when I put a button in, the "onclick" event is not raising. When I use a dropDownList, if I select "autoPostBack", the event raises normaly (instead, nothing occours). But with buttons I cannot define the "autoPostBack" (its implicit?). It's bringing me several troubles.
Thank you if you can help.
I've discovered the problem (moreover two problems): I'm using AjaxControlToolKit MaskEditExtenders and MaskEditValidators, and a PopUpControlExtender. When the form isn't fulfilled correctly, the MaskEditExtenders/Validators somehow disables form submiting. Also, TargetControlID property of popupControlExtender was set to the button in question. In this case, the event isn't raised.
I have a datalist and want to dynamically add buttons to it. I am using the OnItemCommand datalist event and setting the CommandName/ CommandArgument attributes of the button.
However I am having trouble with handling the button click - does not seem to fire.
It works when I declared a button on the aspx page, but not for buttons that are dynamically created.
I hope this makes sense, and any help would be great.
Thanks
You can only create dynamic controls on PreInit or Init if you want to handle associated events. Otherwise, on postback, they won't exist at the moment of event handling and because of that, your handler method won't be called.
Internet is full of resources about how to handle dynamic controls. Let me know if you need any reference.
I am building a user registration form in asp.net. I want to check if the username is available or not on the leave event of the TextBox. I am not able to get the Leave Event of the TextBox.
Should I use OnBlur event of the Html TextBox.
Please Help.
How about using TextChanged server-side event and wrapping the whole thing in an UpdatePanel for very quick ajax functionality.
If you use this method make sure the AutoPostBack property is set to true for the TextBox control.
Short version
All I need is that, in a ModalPopUp, when the DoubleClick event of a ListItem fires, the click event of my OK button should be executed.
Detail
I have a ModalPopUpExtender, which hosts a user control. The user control has an OK and a Cancel button. Along with that, it has a dynamic ListBox added to it. So far, I've considered the following possible solutions:
Use Ajax.Net. But, I cannot afford to have a WebMethod.
Use a ClientScriptCallBack. This will need a lot of JavaScript, since I have made almost every control dynamic.
Is there any other way apart from using an UpdatePanel?
Have a look at this way using __doPostback
calling a VB.net function from javascript