DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 27 Jul 2007 12:34:39 -0500,    posted on: microsoft.public.dotnet.framework.aspnet.buildingcontrols        back       

Thread Index
  1    TS am
          2    (Walter Wang [MSFT])
                 3    TS am


dropdownlist - hooking into the onselectedindexchanged event renders onchange html attribute   
i have an inherited ddl and i have a property (OnChangeFunction) that when
set will add an onchange attribute to it which will call the JavaScript
method used in (OnChangeFunction). the problem is that it interacts with the
one created when assigning onselectedindexchanged to a server side event
handler; so what happens is two onchange html attributes are rendered.

i want to make it so my JS function call (specified in OnChangeFunction)
gets added as the first item in the onchange html attirbute when the
onselectedindexchanged is used, otherwise manually create the onchange
attribute.

what can i do?

thanks
Date:Fri, 27 Jul 2007 12:34:39 -0500   Author:  

RE: dropdownlist - hooking into the onselectedindexchanged event renders onchange html attribute   
Hi TS,

Without full code listing, I cannot reproduce the issue on my side clearly. 
However, it's recommended to add your javascript or assign javascript 
functions to the client-side events in OnPreRender:

    public class Class1 : DropDownList 
    {

        protected override void OnPreRender(EventArgs e)
        {
            Attributes.Add("onchange", "javascript:alert('changed!')");

            base.OnPreRender(e);
        }
    }


Please post your code here if this doesn't help. Thanks.


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Mon, 30 Jul 2007 06:34:14 GMT   Author:  

Re: dropdownlist - hooking into the onselectedindexchanged event renders onchange html attribute   
that works, thanks

"Walter Wang [MSFT]"  wrote in message
news:cSeerOn0HHA.5836@TK2MSFTNGHUB02.phx.gbl...

> Hi TS,
>
> Without full code listing, I cannot reproduce the issue on my side
clearly.
> However, it's recommended to add your javascript or assign javascript
> functions to the client-side events in OnPreRender:
>
>     public class Class1 : DropDownList
>     {
>
>         protected override void OnPreRender(EventArgs e)
>         {
>             Attributes.Add("onchange", "javascript:alert('changed!')");
>
>             base.OnPreRender(e);
>         }
>     }
>
>
> Please post your code here if this doesn't help. Thanks.
>
>
> Regards,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
Date:Mon, 30 Jul 2007 08:46:06 -0500   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us