CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2004
    Location
    Mexico City
    Posts
    96

    Talking Executing a hyperlink when a button clicks

    Hello:
    I have a web form where I have a button and a hyperlink.
    When user clicks the button I change Text and NavigateUrl properties of hyperlink, then user need to clicks hyperlink to open another web page.
    How can I achieve that when user clicks the button, be launched the clicks in hyperlink, if I achieve it I’ll save user to clicks hyperlink.
    I’ll appreciate all your suggestions.
    A.L.
    El hombre que tiene amigos ha de mostrarse amigo...

  2. #2
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201
    Code:
        System.Diagnostics.Process.Start(
            "http://www.whatever.com");
    Regards,
    Hal
    up·grade (up'gräd'),
    to take out old bugs
    and put in new ones.

  3. #3
    Join Date
    Apr 2004
    Location
    Mexico City
    Posts
    96
    Hello Hal:
    When I try to run your code I got an error telling me that I attemted to reference a symbol that doesn't exist.
    Why?
    Regards
    A.L.
    El hombre que tiene amigos ha de mostrarse amigo...

  4. #4
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201
    I have never seen that error before. Here is the OnClick method from a test program I just created:
    Code:
    private void button1_Click(object sender, System.EventArgs e)
    {
        System.Diagnostics.Process.Start(
             "http://www.haldeemar.com/hal");
    }
    Please post you code.

    Regards,
    Hal
    up·grade (up'gräd'),
    to take out old bugs
    and put in new ones.

  5. #5
    Join Date
    Apr 2004
    Location
    Mexico City
    Posts
    96
    Hello Hal:
    I attach my code.

    private void Button1_Click(object sender, System.EventArgs e)
    {
    if(ListBox1.Items.Count != 0)
    {
    if(ListBox1.SelectedItem != null)
    {
    string leyenda = "";
    this.HyperLink1.Text = ListBox1.SelectedItem.Text;
    this.HyperLink1.NavigateUrl = ListBox1.SelectedItem.Text;
    leyenda = ListBox1.SelectedItem.Text;
    System.Diagnostics.Process.Start("leyenda");
    }
    }
    }

    leyenda contnts is = "C:\Documents and Settings\Adolfo\Mis documentos\269.JPG"

    Really I want to open a .JPG document

    Regards.
    A.L.
    El hombre que tiene amigos ha de mostrarse amigo...

  6. #6
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201
    System.Diagnostics.Process.Start is looking for an object named leyenda (since you have it in double quotes).

    If leyenda is a variable it should be
    Code:
    System.Diagnostics.Process.Start(leyenda);
    Regards,
    Hal
    up·grade (up'gräd'),
    to take out old bugs
    and put in new ones.

  7. #7
    Join Date
    Apr 2004
    Location
    Mexico City
    Posts
    96
    I put as you said but continue with same error.

    Just a guy wrote me and his suggestion work OK:

    Response.Redirect(leyenda);

    Thanks you Hal, very much
    El hombre que tiene amigos ha de mostrarse amigo...

  8. #8
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201
    Glad you got it working.

    Regards,
    Hal
    up·grade (up'gräd'),
    to take out old bugs
    and put in new ones.

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

Featured