Skip to main content

Microsoft Silverlight

ScriptAttribute ProblemRSS Feed

(0)

Darren9962
Darren9962

Member

Member

5 points

24 Posts

ScriptAttribute Problem

Hi,

 I'm having a problem with creating a ScriptableMember.  I added this code to my project:

 

using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Browser;
using Telerik.Windows.Controls;
using AMRSilverlight.AlchemySilverlight;
using AMRSilverlight.DataSources;
using System;

namespace AMRSilverlight
{
public partial class MedDlg : UserControl
{
private bool changingValues = false;
private bool loading = false;
private string _ptGUID = String.Empty;
private string _findMed = String.Empty;

public MedDlg()
{
loading = true;

InitializeComponent();

Loaded += new RoutedEventHandler(MedDlg_Loaded);

...

loading = false;
}

private void MedDlg_Loaded(object sender, RoutedEventArgs e)
{
HtmlPage.RegisterScriptableObject("MedDlg", this);
}

public MedDlg(string ptGUID, string findMed)
: this()
{
_ptGUID = ptGUID;
_findMed = findMed;
}

[ScriptableMember]
public void Dummy(string dummy)
{
Console.WriteLine(dummy);
}

...

}
}
 I got a runtime exception about my object not having any scriptable members.  I rem'd out these lines
            Loaded += new RoutedEventHandler(MedDlg_Loaded);
  HtmlPage.RegisterScriptableObject("MedDlg", this);
         [ScriptableMember]
public void Dummy(string dummy)
{
Console.WriteLine(dummy);
}
and I still get the exception.  What am I doing wrong?
 
Thanks,
Darren 

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: ScriptAttribute Problem

Very strange, this doesn't look like something is wrong. But then again, are you sure you did a rebuild and a refresh in the browser? Definitely looks like you're looking to old code. If this doesn't solve anything, can you post your complete solution somewhere? So I or other forum members can take a look at it? I think you want to communicate with the html, maybe there's something strange in there.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

Darren9962
Darren9962

Member

Member

5 points

24 Posts

Re: ScriptAttribute Problem

Thanks for your response!

 Yes, I cleaned the solution and rebuilt it.  Same result.  I duplicated the relevent portion of the code into a different project and it worked.  I can't even duplicate the problem in another project.

 

Could there be something something wrong with my ASPX?

  

<%@ Page Title="" Language="C#" MasterPageFile="~/Base/View/Dialog.master" AutoEventWireup="true" CodeFile="MedDlg2.aspx.cs" Inherits="AMR.Main.Med.MedDlg2" %>

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>
    
"Content1" ContentPlaceHolderID="HeadPlaceHolder" Runat="Server">

"Content2" ContentPlaceHolderID="FooterPlaceHolder" Runat="Server">

"Content3" ContentPlaceHolderID="HeaderPlaceHolder" Runat="Server">

"Content4" ContentPlaceHolderID="SideBarPlaceHolder" Runat="Server">

"Content5" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    "ScriptManager1" runat="server">
    
"MedDlgSection" style="width:320px;height:320px;"> "MedDlgControl" runat="server" InitParameters="Page=MedDlg" Source="~/ClientBin/AMRSilverlight.xap" MinimumVersion="2.0.31005.0" Width="320px" Height="320px" >
I'm new to Silverlight and I appreciate your help.
 
  

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities