|
-
July 9th, 2004, 09:42 AM
#1
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...
-
July 9th, 2004, 10:49 AM
#2
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.
-
July 9th, 2004, 01:38 PM
#3
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...
-
July 9th, 2004, 02:13 PM
#4
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.
-
July 9th, 2004, 04:59 PM
#5
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...
-
July 9th, 2004, 05:09 PM
#6
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.
-
July 9th, 2004, 05:20 PM
#7
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...
-
July 9th, 2004, 05:28 PM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|