locked
Calling another .asp file RRS feed

  • Question

  • I have created a global .asp file that contains global variables that could be used by many pages. As I am new to the world of .asp I do not know how to call this page from within another page (using the redirect command) and then have it return to the same point in the page that called it (or if that's even possible).

    Another option would be to call the global page with a parameter and based on that parameter redirect to another page that will actually make use of the global variables. I am guessing that is what I will have to do if there is not another method.

    Thanks.

    • Moved by Mike Feng Monday, November 7, 2011 7:36 AM ASP (From:Visual Basic General)
    Thursday, November 3, 2011 3:43 PM

Answers

All replies

  • Sorry, should have clarified. I am actually writing it in C# using Sharepoint designer.
    Thursday, November 3, 2011 6:55 PM
  • Hello,

    I believe you're confusing global variables with session variables.

    Global variable only have scope with the page.

    Session variables have scope through the site while the session is active.

    Adam


    Already reported as abusive
    Thursday, November 3, 2011 6:58 PM
  • Andrew,

    I believe you're confusing Global with Public but it's been a long day and I don't want to split hairs with you.

    Adam


    Already reported as abusive
    Thursday, November 3, 2011 7:26 PM
  • Andrew,

    I believe you're confusing Global with Public but it's been a long day and I don't want to split hairs with you.

    Adam


    Already reported as abusive

    This is why your signature reads the way it does.  You're utterly clueless but you want to argue with somebody anyway, and more often than not you pick me for no apparent reason.

    So how about if you define a Global Variable vs a Public Variable vs an Internal Variable and while you're at it fill us all in on the differences between the Windows Forms Application lifecycle vs the ASP.NET Page and Session lifecycles?  Then we can all know what you think you're babbling about when you're really just bloating MSDN with nonsense that will actually hurt readers who don't know any better.


    It never hurts to try. In a worst case scenario, you'll learn from it.

    If I'm hurting you Andrew, because you're a reader that doesn't know any better, I apologize.
    Already reported as abusive
    Thursday, November 3, 2011 7:43 PM
  • Adam, you hit on what I am looking for. I should have used the word session (global in my sense is that I would have one page in a central location that would be called globally by other pages). Basically what I want to do is call the .asp file, assign values to a session variable then return to the original page and pick up where it left off. Hopefully I have gotten all my terminoolgy straightened out.
    Thursday, November 3, 2011 8:17 PM
  • Well,

    There are many ways to accomplish that.

    If the data isn't sensitive, you can use a querystring.

    You can use Session_Start in the global.asax file to set session variables and access them througout the pages.

    You can pass xml around via XMLHTTP posts.

    You can write the data to a database.

    With the new frameworks, you can even pass values from page to page via viewstate.

    You can cache it and you can even write it to a cookie.

    It's really up to you on how you want to do it.

    Adam


    Already reported as abusive
    • Edited by Adam_Turner Friday, November 4, 2011 1:28 PM
    Friday, November 4, 2011 1:27 PM
  • You can find help for Classic ASP and ASP.NET at the below links. This forum is primarily for Visual Basic.

    http://forums.iis.net/1032.aspx

    http://forums.asp.net/


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Friday, November 4, 2011 1:40 PM
  • You can find help for Classic ASP and ASP.NET at the below links. This forum is primarily for Visual Basic.

    http://forums.iis.net/1032.aspx

    http://forums.asp.net/


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Mr. Clement,

    You know probably much more than VB than me, but AFAIK is VB since version VB6 also for .Net, where ASP.Net a main section is from. 

    Or do you want to say that this is a VB6 forum, where the only taste is Windows Forms?

    The question can be done by using the VB code.

     

        Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Page.Response.Redirect("http://www.Microsoft.com")
        End Sub
    

    Be aware the same can be done for an ASP. page. It is tested and runs.

    (Be aware that is impossible in VB6, so maybe am I violating this forum putting VB for Visual Studio Net code inside this forum)

     


    Success
    Cor

    Friday, November 4, 2011 2:42 PM
  • Mr. Clement? Why so formal Monsieur Ligthert? ;-)

    The OP indicated ".asp", which refers to Classic ASP. Any questions regarding web app design can be best answered in a web app forum.

    BTW, a Redirect navigates to a different page - there will be no return to the source page as the OP requested.


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Friday, November 4, 2011 3:06 PM
  •  

    The OP indicated ".asp", which refers to Classic ASP. Any questions regarding web app design can be best answered in a web app forum.

     

    Paul,

    I had seen that long before you, but that is not done in the ASP.Net forums, so don't bother those guys and girls with questions which don't belong in that forum. Beside that can you simply using VB redirect in ASPX to an ASP page. Like you see in my latest reply with code proven.

    Be aware if you had written for the global asp file visit the IIS forum, I had not given this reply. The mean reason was that I write this that you to Microsoft newbies give the idea that this is a likewise VB6 forum.

    Visual Basic in the VSN versions for this forum can be used with.

    Asp.Net, MVC, WPF, SilverLight, Office, WFC, Windows Service, Phone, WP7, Xbox, Console applications, and even much more including still Windows Forms.

    Many of those like Windows Forms are just presentation layers which are used by VB. The presentation aspects can be the best be done in the special forums for those. But as it is professional not unusual to create one solution with different layers from which the presentation ones are one layer, can the complete solution in my idea better be done in a general program language forum which binds those presentation layers together.

    For the Express forums are beside WPF and Console all the above of topic, but this is not the Express forum.

     


    Success
    Cor

    Friday, November 4, 2011 4:36 PM
  • To redirect to another page and then return to where you were you can use the Page.Response.Execute() method.

    That said, from what you've described about your problem this doesn't seem to be a good way to go about solving it.

    You should be able to do this by simply using static methods/properties of some class to call some common piece of code from many different locations.

    Friday, November 4, 2011 4:51 PM