Thread: C#: Server.Execute() and Server.Transfer()

  1. #1
    Registered User Grayson_Peddie's Avatar
    Join Date
    May 2002
    Posts
    96

    C#: Server.Execute() and Server.Transfer()

    IDE and Version: Visual C# .net 2002
    .net Framework version: .net Freamework 1.1
    Problem: Trying to instruct ASP.net to load another page from when a button has clicked.
    Control Used: Image Button
    Name of an image button: News
    ID for the button: GPNews
    Code for the News buton:
    Code:
    private void GPNews_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        if(!Page.IsPostBack)
        {
            Server.Execute("http://www.future-gpnet.com/news/news.aspx");
        }
    }
    News page loaded successful?: No.
    Attempt 2 - code for the News Button:
    Code:
    private void GPNews_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        Server.Execute("http://www.future-gpnet.com/news/news.aspx");
    }
    Page loaded succesfully: No.
    Attempt 3 - code for the News Button:
    Code:
    private Page_Load(object sender, System.EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            btnGP.Click += new System.Web.UI.ImageClickEventHandle(this.GPNews_Click);
        }
    }
     
    private void GPNews_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        Server.Execute("http://www.future-gpnet.com/news/news.aspx");
    }
    Page Loaded successfully when the user clicked the News button?: No.
    Web Hosting Service: UpLinkEarth
    ASP.net version for UpLinkEarth: ASP.net 1.0
    # of projects in Solution Explorer: 2
    Name of projects in Solution Explorer: www.future-gpnet.com; News

    Hi, there. I have problems when trying to execute (load) another page like the News Page when a user clicked a News button. I had tried 3 attempts for loading the page up but it wouldn't work. Well, I can tell that since UpLinkEarth uses .net Framework 1.0 (which contain ASP.net 1.0), then it sounds like it's not compatible with .net Framework 1.1... Since UpLinkEarth will be in maintenance mode in third week of October (Wednesday at 9:00 PM and ends on Thursday 4:00 AM), is there a workaround in how to make ASP.net execute a code when a user clicked or do I have to wait since during the UpLinkEarth's maintenance mode, UpLinkEarth are going to be installing .net Framework 1.1 (which contain ASP.net 1.1).

    Thanks for taking your time reading my thread.

    EDIT1: Made some mistakes in my code...
    Last edited by Grayson_Peddie; 09-22-2003 at 10:52 PM.
    View in Braille.
    http://www.future-gpnet.com/braille.jpg

    Like a bolt out of the BLUE,
    Fate steps up and sees you THROUGH,
    When you wish upon a STAR
    YOUR DREAMS COME TRUE.

  2. #2
    Registered User Grayson_Peddie's Avatar
    Join Date
    May 2002
    Posts
    96
    Hey can someone help me out here?

    I tried "Server.Transfer("index.aspx");" and it works.

    Executing "Server.Transfer("Index.aspx");" returns a path in the URL:

    "www.future-gpnet.com/index.aspx".

    How do I execute a file called "News.aspx" inside a News folder?

    What I'm trying to execute is:

    "www.future-gpnet.com/news/news.aspx"

    Thanks.
    View in Braille.
    http://www.future-gpnet.com/braille.jpg

    Like a bolt out of the BLUE,
    Fate steps up and sees you THROUGH,
    When you wish upon a STAR
    YOUR DREAMS COME TRUE.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    If this works:
    "Server.Transfer("index.aspx");"

    have you tried
    "Server.Transfer("news/news.aspx");"
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User Grayson_Peddie's Avatar
    Join Date
    May 2002
    Posts
    96
    It didn't work but I tried the Redirect mothod from the Page.Response. Thank you for your help.
    View in Braille.
    http://www.future-gpnet.com/braille.jpg

    Like a bolt out of the BLUE,
    Fate steps up and sees you THROUGH,
    When you wish upon a STAR
    YOUR DREAMS COME TRUE.

Popular pages Recent additions subscribe to a feed