This is a migrated thread and some comments may be shown as answers.

How to find silverlight control in Notification object

5 Answers 73 Views
Notification
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 03 Aug 2011, 05:53 AM
I have a custom silverlight control that is placed inside the ContentTemplate of the RadNotification control.  I am having problems finding this custom silverlight control within Javascript so that I can pass values to the silverlight control through a scriptable member.  Basically, what I am trying to do is use the RadNotification control to check for any changes in value using the UpdateInterval and OnCallbackUpdate members.  The OnCallbackUpdate sets static variables on the server side that is used by javascript to pass to the silverlight control.  If the values have changed then the Nofication control is told to show, if the values are the same then the control remains hidden.  I have everything working except being able to find my silverlight control embeded within the RadNotification contentTemplate so that I can reference the object in my javascript and call my silverlight scriptable member.

RadNotification Declaration:
<telerik:RadNotification ID="RadNotification1" runat="server" Width="380" Height="100"
        Animation="Fade" EnableRoundedCorners="true" VisibleTitlebar="false" OnClientUpdated="showNotification"
        OffsetY="-400" OffsetX="-500" Value="false"  AutoCloseDelay="3000" UpdateInterval="6000" LoadContentOn="TimeInterval" OnCallbackUpdate="resetNotification">
        <ContentTemplate>
        <object id="silver2" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="380" height="100">
                      <param name="source" value="../ClientBin/Notification.xap"/>
                      <param name="onError" value="onSilverlightError" />
                      <param name="background" value="Transparent" />
                      <param name="windowless" value="true" />
                      <param name="pluginbackground" value="Transparent" />
                      <param name="minRuntimeVersion" value="4.0.50826.0" />
                      <param name="autoUpgrade" value="true" />
                      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
                          <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
                      </a>
                    </object>
        </ContentTemplate>
        </telerik:RadNotification>


OnCallbackUpdate
protected void resetNotification(object sender, RadNotificationEventArgs e)
       {
           RadNotification1.Value = "false";
           if(Queue.Count>0)
           {
                     var s = Queue.Dequeue();
                   value 1 = s.Value1;
                   value 2 = s.value2;        
                   value3 = s.value3;
                 RadNotification1.Value = "true";
                 
           }
            
       }

Javascript
function showNotification(sender, args) {
                 
  
                var showMsg = sender.get_value()
                if (showMsg == "true") {
                    sender.show();
                      
               var silverlightplugin = $get("silver2");
  
               var content = silverlightplugin.content;
               content.MainPage.BindValues(value1,value2,value3);
                }
                 
  
            }

5 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 03 Aug 2011, 01:47 PM
Hello Greg,

I think it's something simple as, silverlightplugin.Content, uppercase C, not lowercase.

I hope that helps.
0
Greg
Top achievements
Rank 1
answered on 03 Aug 2011, 02:08 PM
I tried your suggestion, and I am still recieving an invalid pointer exception.
0
Marin Bratanov
Telerik team
answered on 04 Aug 2011, 02:44 PM
Hi Greg,

Does this code work outside of the RadNotification? Is is possible that you actually get a correct reference to the silver2 <object>, yet the code fails at a later stage in the Silverlight-related section? I am asking this because there is no reason for the $get() method to fail to return the DOM element, as it is not a server control, so its ID will not be changed by the framework.

Therefore I believe that this issue is not related to the RadNotification or to the Javascript, actually, and what I can assume for now is that the Silverlight code is not configured to work with JavaScript. Please examine the following net resources on the matter:
http://stackoverflow.com/questions/2051092/how-to-call-javascript-function-on-a-silverlight-3-object
http://msdn.microsoft.com/en-us/library/cc221414(v=VS.95).aspx#Y960

I hope they will help you resolve the situation, as Silverlight is not in the scope of the ASP.NET AJAX controls suite.

Kind regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Greg
Top achievements
Rank 1
answered on 07 Aug 2011, 05:18 AM
The silverlight works fine outside of the content template for the Radnotification control.  When I place the control inside the content Template then once the RadNotification reaches the interval to check for updates and displays the notification the silverlight object comes back as undefined.  So, I do not think it is an issue with the silverlight control since I can reference or find the control when it is not being used inside of the RadNotification control. I was able to use $get, $find, and documentByID methods to find the control with no problem outside of the notification control.  I was trying to take a short cut to creating a notification system that embeded a silverlight media object to play thumbnail previews of a video file. 

I ended up just taking the long route and building the notification control completly in silverlight by creating a TCP socket policy and messaging server to pass notifications from the server to each of the connected silverlight clients.  I hope their are plans for you guys to build a notification system for your silverlight controls. 
0
Marin Bratanov
Telerik team
answered on 08 Aug 2011, 12:38 PM
Hello Greg,

  From your previous post I was under the impression that the issue is observed not only after a callback. If this is the case then this may be due to a bug related to the execution of scripts after a callback, which has already been fixed. Please try the latest internal build and see if this fixes the issue. In case you do not wish to use internal builds you can try the following workaround and see if it helps:
function pageLoad() {
            var xmlPanel = $find("<%= RadNotification1.ClientID %>")._xmlPanel;
            xmlPanel.set_enableClientScriptEvaluation(true);
        }

We than you for your interest in a notification control for the Silverlight suite. I cannot provide an estimate if such a control will be included in the future, but I am sorry to say that currently there are no immediate plans on including it.


All the best,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Notification
Asked by
Greg
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Greg
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or