How to Redirect to a URL via VB - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to Redirect to a URL via VB

Last post 05-07-2009 07:19 AM by Samir Farid. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 04-29-2009 01:00 PM

    How to Redirect to a URL via VB

    Guys:

     From this question, I'm sure you guys would be able to quickly tell I'm a true newbie.  I've been looking for this answer for a few hours though - and have found solutions, but none of which are working in my InfoPath form.

     Here's the thing...  I need to redirect my web-enabled InfoPath form to another web page via VB when the user clicks on a partiular button. 

    The part thiat I'm missing is simply the VB code to redirect the user accordingly.  I've found and tried this code:

    [ Response.Redirect("http://www. google.com") ], but it gives me a "Name 'Response' is not declared' error.

     I know this is crazy simple, but I just can't seem to find anything that works.  Any help would be GREATLY appreciated.  Thanx!

     

     - Tav

     

    - Tav
  • 04-29-2009 05:17 PM In reply to

    Re: How to Redirect to a URL via VB

    Hi Tav,

    I haven't tried this out yet, but you could probably do the following:

    1. First of all, you have to add a reference to the System.Web namespace in your project.

    2. Add an Imports statement in your code "Imports System.Web;"

    3. Use the following code:

    HttpContext.Current.Response.Redirect("http://www.infopathdev.com);

    Let me know if this worked for you.

    Regards,

    Samir

  • 05-05-2009 12:18 PM In reply to

    Re: How to Redirect to a URL via VB

    Samir,

     Thanx for your input.  Unfortunately this did not work for me.  I got an error when try to run it via the browser, and this error (below) when I run it via the client:

    System.Security.SecurityException
    Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
       at WOTS_FIX5.FormCode.CTRL15_5_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

     Have any more ideas??

     

    - Tav

    - Tav
  • 05-07-2009 07:12 AM In reply to

    Re: How to Redirect to a URL via VB

    Just to give you guys an update regarding the resolution I found for this problem (as I know how such resolutions help me when I need them), this is the code (below) that I used to get my redirects working via VB...

    Kudos to Samir for stearing me in the right direction too btw...

                 Dim rURL As String = String.Empty
                rURL = "
    http://www.google.com"
                HttpContext.Current.Response.Redirect(rURL.ToString(), False)

    I still used Samir's steps (above) which are:

     1. First of all, you have to add a reference to the System.Web namespace in your project.

    2. Add an Imports statement in your code "Imports System.Web;"

    I just substitued my code in for step # 3.  Oh, and I also had to change my form's security settings to "Full" via the following steps:

    1.  "Tools (menu)  >>  Form Options  >>  Secuirty & Trust" tab

    2.  Unchecking "Automatically determine security level (recommended)" checkbox, and selecting the "Full Trust (the form has access content from the domain in which it is located)" radio button...

    After doing-so, my form redirect to whatever URL I specified upon submit via VB code!!  Note that the button I appended this code to was my "submit" button of course, and I appended this code as the last block of the button's code (of course) so the redirection is the last thing that happens.

     I hope this helps anybody out there who's trying to do this via VB Script!

     

    - Tavalanche

    - Tav
  • 05-07-2009 07:19 AM In reply to

    Re: How to Redirect to a URL via VB

    Nice going, I'm glad I could help.

    Kind Regards,

    Samir

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.