Results 1 to 10 of 10

Thread: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2010
    Location
    DC Metro area
    Posts
    53

    2010 ASP.NET Silverlight Embedded Control Not Firing Events

    I have a solution that includes two projects. One is a Silverlight folder browser project embedded into the a div on the second project's aspx page and runs as a Out of Browser application. The problem I am experiencing is with the Silverlight folder browser project. All functions operate as expected when running as the startup project, solely, by itself outside of the aspx page. However no events are firing when running the Silverlight folder browser in the aspx page. Nothing is triggering the breakpoints. What could be the problem? I can provide whatever code necessary. Thanks.



    Code:
    namespace AccessingEntireFileSystemInSL5Beta
    {
        public partial class MainPage : UserControl
        {
            EntireFileSystem fileSystem = null;
    
            public MainPage()
            {
                InitializeComponent();
    
    
                // Register script for opening browser in Preferences.aspx page - using via System.Windows.Browser;
                //HtmlPage.RegisterScriptableObject("Page", this);
    
                // Register Silverlight to be exposed in JavaScript 
                HtmlPage.RegisterScriptableObject("ScriptablePageObject", this); 
    
                fileSystem = new EntireFileSystem();
    
                this.folderName.Text = "Folder path : Not selected";
    
                this.lstFiles.ItemsSource = new List<string>() { "No files in the current folder ! " };
    
                this.myTreeView.DataContext = fileSystem.RootFolder;
                
            }
    
    
            private void myTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
            {
                Folder folder = e.NewValue as Folder;
    
                // If the folder is not null
                if (folder != null)
                {
    
                    // If the full folder path is not null or empty, and child folders do not exist or the folder title is My Computer
                    if ((!string.IsNullOrEmpty(folder.FullPath)
                           && folder.ChildFolders.Count == 0)
                           || folder.Title.Equals("My Computer"))
                    {
    
                        // Load the subfolders for the top level folder, and show the directory
                        fileSystem.LoadSubFolders(folder.FullPath, folder);
    
                        // Show the current folder selection
                        this.folderName.Text = "Folder path : " + folder.FullPath;
                    }
    
                    // Create a list to hold the file info for the selected folder
                    List<string> fileInfo = new List<string>();
    
                    try
                    {
                        foreach (string fileName in Directory.EnumerateFiles(folder.FullPath))
                        {
                            FileInfo file = new FileInfo(fileName);
                            string size = (file.Length / 1024 / 1024) == 0
                                          ? "Less than 1"
                                          : (file.Length / 1024 / 1024).ToString();
                            fileInfo.Add(file.FullName + " |  Size : " + size + " MB |  Created on: "
                                                       + file.CreationTime);
                        }
    
                        // The following displays a message if there are no files in the selected folder
                        // This is not required for this project
                        if (fileInfo.Count == 0)
                        {
                            this.lstFiles.ItemsSource = new List<string>() { "No files in the current folder ! " };
    
    
                        }
                        else
    
                            // Else, there are files in the folder, so show the file's info
                            // held within the fileInfo list of strings
                            lstFiles.ItemsSource = fileInfo;
                    }
    
                        // Catch the exception that will occur when initiating from the top level 
                    catch (Exception) { }
                }
            }
    
    
    
    
            private void RefreshMyComputer(object sender, RoutedEventArgs e)
            {
                fileSystem.LoadFolder();
                myTreeView.ItemsSource = fileSystem.RootFolder;
            }
    
            // This function is called from the Apply button and sends the value of the selected path
            // to the asmx page
            [ScriptableMember]
            public void btnApply_Click(object sender, RoutedEventArgs e)
            {
                HtmlPage.Window.Invoke("getFolderPath", folderName.Text);
    
            }
    
        }
    }
    HTML Code:
    <div id="SilverlightControlHost" class="slidingDiv" style="display: block;">
    
                        <object ID="SilverlightPlugin1" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="508px" height="350px">
                        
                            <param name="source" value="ClientBin/AccessingEntireFileSystemInSL5Beta.xap" />
                            <param name="onerror" value="onSilverlightError" />
                            <param name="background" value="white" />
                            <param name="minRuntimeVersion" value="4.0.60310.0" />
                            <param name="autoUpgrade" value="true" />
                            <param name="isWindowLess" value="true" />
    
                            <!-- Display installation image. -->
                            <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=4.0.60310.0" style="text-decoration: none;">
    
                            <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style: none"/>
                        
                            </a>
                        </object>
                        <iframe id="_sl_historyFrame" 
                            style='visibility:hidden;height:0px;width:0px;border:0px'>
                        </iframe>
    
                    </div>

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,684

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    Hi. Maybe you can ask at the silverlight forum on this site and get an answer but why are u using silverlight? It will be deprecated soon anyhow, only Microsoft use it.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    Quote Originally Posted by sapator View Post
    Hi. Maybe you can ask at the silverlight forum on this site and get an answer but why are u using silverlight? It will be deprecated soon anyhow, only Microsoft use it.
    Personally, I think that deprecated is too strong a word, that is not really the case. While Silverlight has been "passed over" for a more generic style of application development, namely HTML 5, JavaScript and CSS, Silverlight is still a perfectly viable option of Line of Business Applications. There are a ton of things that you can do in Silverlight that you can't, and will likely never, be able to do in HTML 5, JavaScript and CSS. Depending on your use case, it still makes a lot of sense to develop in Silverlight.

    With regard to the question...

    Let me see if I have this right. When you debug the ASP.Net Application, as the start up project, the embedded Silverlight Application is rendered to the page, but you can't step into the code in the debugger. However, if you set the Silverlight Project as the start up project, you can bring it up in the browser, and you are able to debug as you would expect?

    Does that about sum it up?

    Gary

    P.S. This does sound like a Silverlight specific problem, so I am going to move it to the Silverlight Forum

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2010
    Location
    DC Metro area
    Posts
    53

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    gep13 - Yes, you are partially correct. The application does compile and steps through debugger when set as the startup project. However, it is a out of browser app so it does not open in a browser. The application opens up independently, in it's own bordered form window because I changed it to the startup project for testing purposes.

    When the solution is setup with the main project as the startup project, a web application, the File Browser Silverlight app renders in a div but does not fire events.

  5. #5
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,684

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    I've read and posted to this forum that Microsoft will deprecate Silverlight as an entity. I cannot find my post and thus the info. So it is not me that says that it will be deprecated but Microsoft.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    Quote Originally Posted by sapator View Post
    I've read and posted to this forum that Microsoft will deprecate Silverlight as an entity. I cannot find my post and thus the info. So it is not me that says that it will be deprecated but Microsoft.
    It is my understanding, as per the information here:

    http://support.microsoft.com/gp/lifean45

    The Microsoft will continue to support Silverlight 5 until 2021. There are no plans for a new Siliverlight version, Silverlight 5 is as far as it is going to go, but any security vulnerabilities that are identified will be corrected up to 2021. That, to me at least, doesn't look like it's deprecated. I agree that there is no active development happening on it, but this is the same as Visual Basic 6, and people are still using that.

    Silverlight still has it's place, in my opinion.

    Gary

  7. #7
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,684

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    It's somewhat the same with VB6, with the difference that VB6 had 10 million programmers using it and silverlight has 7.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2010
    Location
    DC Metro area
    Posts
    53

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    Does anyone have an idea where I can begin troubleshooting this issue?

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    Quote Originally Posted by gixxer05 View Post
    Does anyone have an idea where I can begin troubleshooting this issue?
    In post 3, I asked for some more information in order to help you. Can you answer those questions?

    Gary

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: 2010 ASP.NET Silverlight Embedded Control Not Firing Events

    Quote Originally Posted by sapator View Post
    It's somewhat the same with VB6, with the difference that VB6 had 10 million programmers using it and silverlight has 7.
    I think you are under estimating how much it is used in Enterprises.

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width