This Forum is ARCHIVE only
For LightSwitch questions,
please use the official forums at:

http://social.msdn.microsoft.com/forums/en-US/lightswitch/threads


How to call a HyperLink
Last Post 24 Jan 2012 06:06 AM by admin. 12 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Informative
Garth HendersonUser is Offline
New Member
New Member
Send Private Message
Posts:91
Avatar

--
07 Jun 2011 06:04 AM

    I got this from the LS forum, others get the credit, not me:

    public void CallHyperLink(string navigateUri)
    {
        Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(() =>
        {
            if (AutomationFactory.IsAvailable)
            {
                dynamic shell = AutomationFactory.CreateObject("Shell.Application");
                shell.ShellExecute(navigateUri.ToString());
            }
            else if (!System.Windows.Application.Current.IsRunningOutOfBrowser)
            {
                System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(navigateUri) , "_blank");
            }
            else
            {
                throw new InvalidOperationException();
            }
     
        });
    }

     

    Garth Henderson
    365 Solutions Group
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    07 Jun 2011 06:09 AM
    Thank you Garth. The example I had posted at: 
     
    http://lightswitchhelpwebsite.com/F...fault.aspx

    only coveres "web deployed LightSwitch applications". Your example covers both.
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Scott99User is Offline
    New Member
    New Member
    Send Private Message
    Posts:3
    Avatar

    --
    12 Jun 2011 08:38 AM
    Thanks for the tip, however can this method also be used for POSTing data to another website? I would like to 'hand-off' my user to a 3rd party payment processor, in certain business flows. Thanks for any insight....
    Garth HendersonUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:91
    Avatar

    --
    30 Jun 2011 06:03 AM
    @Scott:  You can call any URL with this.  I create complex URL parameters to run SSRS reports.
    Garth Henderson
    365 Solutions Group
    Scott99User is Offline
    New Member
    New Member
    Send Private Message
    Posts:3
    Avatar

    --
    20 Jul 2011 08:03 AM
    Thanks for the advice - the query string limit on a URL is 2048 bytes so that should suffice. I do have that working with key value pairs now appended to the end of the URL - again thanks for your help.

    One other very related question: This solves passing data to another aspx page or web application, but what about reading data passed to a LightSpeed application from another page or web app? My next challenge is to accept a GUID from another application to preserve session state. My application complements a payment processor application that maintains session state for the user so they can pay once - instead of paying multiple times for each transaction they process in my Lightspeed app.

    My first thought was that I should write a custom Silverlight control that could act as a listener to process an HTTP POST from the payment processor app. I would then use the POSTed data in my Lightspeed app.  

     Any thoughts? 
    Scott99User is Offline
    New Member
    New Member
    Send Private Message
    Posts:3
    Avatar

    --
    20 Jul 2011 08:06 AM
    Of course I mean LightSwitch in the post above - not LightSpeed.  I should just use the LS acronym from now on 
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    20 Jul 2011 08:20 AM
    My first thought was that I should write a custom Silverlight control that could act as a listener to process an HTTP POST from the payment processor app. I would then use the POSTed data in my Lightspeed app.

    That is what I would try, however I am not positive it will work (I don't know).
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    ClayHmnUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:2
    Avatar

    --
    09 Oct 2011 06:04 PM
    Can someone translate this into VB for me? Especially how to handle the Dynamic call?
    ClayHmnUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:2
    Avatar

    --
    09 Oct 2011 06:35 PM
    I think I got it...

    Option Strict Off
    Imports System.Runtime.InteropServices.Automation
    'Put this at the top



    If AutomationFactory.IsAvailable Then
                    Dim shell = AutomationFactory.CreateObject("Shell.Application")
                    shell.ShellExecute(myUri)
                ElseIf Not System.Windows.Application.Current.IsRunningOutOfBrowser Then
                    System.Windows.Browser.HtmlPage.Window.Navigate(New Uri(myUri), "_blank") Then
                Else
                    Throw New InvalidOperationException
                End If
    TACIRUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:2
    Avatar

    --
    24 Jan 2012 04:49 AM

    I am trying to implement the following VB code copied from above to print an SSRS report using a button on the command bar of a Web application.  I added the second import to resolve an error. Now get Invalid Cross Thread Access.   Can someone please help.  I have spent two days trying to find a way to simply execute an ssrs report from the web ap.  (Please keep in mind that I am new to LS and not a .net programmer but DBA & TSQL developer)

    'Put this at the top
    Option Strict Off
    Imports System.Runtime.InteropServices.Automation
    Imports System.Windows.OutOfBrowserSettings


    Namespace LightSwitchApplication

        Public Class Staff_List

            Private Sub PrintStaff_Execute()
                ' Write your code here.
                Dim myUri As String = (http://10.171.74.88:8090/Reports/Pages/Report.aspx?ItemPath=%2fThe+Board%2fTACIR+Staff&user=AF12014_sa&pwd=xxxx)

                If AutomationFactory.IsAvailable Then
                    Dim shell = AutomationFactory.CreateObject("Shell.Application")
                    shell.ShellExecute(myUri)
                ElseIf Not System.Windows.Application.Current.IsRunningOutOfBrowser Then
                    'System.Windows.Browser.HtmlPage.Window.Navigate(New Uri(myUri), "_blank")
                Else
                    Throw New InvalidOperationException
                End If

            End Sub
        End Class

    End Namespace

     

    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    24 Jan 2012 05:01 AM
    The code in this article should help (however it's in C#):
    http://lightswitchhelpwebsite.com/B...witch.aspx
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    TACIRUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:2
    Avatar

    --
    24 Jan 2012 05:55 AM
    I have been through the article several times trying to understand.  I have added the references by right clicking on the client.  I have the report deployed to the report server and just want to execute it.  I am trying to do that with the code Garth posted by passing the url including a user id and password, but getting the Invalid cross-thread access.  The StackTrace: at MS.Internal.XcpImports.CheckThread().  I have no idea what this means even after doing some research.  What am I missing in order to be able to use Garth's approach?
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    24 Jan 2012 06:06 AM
    Sorry I only know that my sample code works.
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    You are not authorized to post a reply.


    Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation