[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

dropdownlist - hooking into the onselectedindexchanged event renders onchange html attribute

TS

7/27/2007 5:35:00 PM

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


2 Answers

wawang

7/30/2007 6:34:00 AM

0

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.

TS

7/30/2007 1:46:00 PM

0

that works, thanks

"Walter Wang [MSFT]" <wawang@online.microsoft.com> 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.
>