logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Javascript inside widgets
sankit57
#1 Posted : Wednesday, November 09, 2011 9:17:19 AM(UTC)
Rank: Newbie

Groups: Registered, Customer
Joined: 6/8/2011(UTC)
Posts: 6
Man
Location: Mumbai, India

Hi,

Can we write a javascript function inside a widget? I have a requirement for which i need to set a hidden field with the value selected in the dropdown. Can anyone guid me on this. The drop down and hidden fields are placed on the widget.
tansu
#2 Posted : Wednesday, November 09, 2011 12:16:59 PM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 7/24/2009(UTC)
Posts: 814
Man
Location: Türkiye / Ankara

Was thanked: 1 time(s) in 1 post(s)
Hi,

Yes you can use Javascript functions inside widgets. But there is a trick.

We create your widget after an async postback and a dashboard may have multiple instances of your widget. So to prevent dublication, I recommed you to put all your javascript functions inside a seperate js file and reference this file from the page in which DashboardSurface control is located. Then you can use your functions.

If you just need to set a hidden variable you can also use inline javascript like

<button onclick="javascript:alert('xxx') > ...

-tansu
Tansu TURKOGLU
Development Team
www.dynamicdashboards.net
sankit57
#3 Posted : Thursday, November 24, 2011 10:04:06 AM(UTC)
Rank: Newbie

Groups: Registered, Customer
Joined: 6/8/2011(UTC)
Posts: 6
Man
Location: Mumbai, India

Thanks tansu for the reply. Yes we are doing the same, but there are times when we want to refer to controls using document.getElementById()in the widget itself.
berkay
#4 Posted : Thursday, November 24, 2011 11:59:32 AM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/8/2011(UTC)
Posts: 168
Location: Turkey

Was thanked: 6 time(s) in 6 post(s)
if your control is server control you can call your control shown below.

<button onclick="javascript:alert(document.getElementById('<%= YourControl.ClientID%>').value) >

Regards.
Berkay ERKOY
Development & Support Team
www.dynamicdashboards.net
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


This page was generated in 0.064 seconds.