[C#] Hyperlinking in windows project

Pagina: 1
Acties:

  • BSeB
  • Registratie: Juni 2001
  • Laatst online: 22-09-2025
Ik ben dus bezig met het schirjven van een windows applicatie in C# heb hiervoor wel is wat gemaakt in VB6 en nu wil ik in mijn programma ervoor zorgen dat als ik op een button druk ik een webpagina open in IE (om mee te beginnen, later moet dit in het programma zelf geaan worden).

Nu ben ik al aan het zoeken geweest, want in VB6 ging het met shell, maar .Net is totaal anders, dus was aan het zoeken en kwam het volgende tegen:

// C#
public void Button1_Click (object sender, System.EventArgs e)
{
this.HyperLink1.Text = "Home";
this.HyperLink1.NavigateUrl = "http://www.microsoft.com/net/";
}

Alleen hier heb ik een paar problemen oa met de definitie hyperlink1. Overigens is dit stukje regelrecht uit mijn help gekopieerd.

Nu ben ik dus vastgelopen, want de rest wat ik kan vinden gaat erover op het moment dat ik een website ga maken en dat wil ik dus niet. Hoe kan ik dus wel een webpage openen.

Edit: Ik heb de search gebruikt en ja ik heb de help uitgepluist

[ Voor 5% gewijzigd door BSeB op 14-02-2003 14:44 ]


  • whoami
  • Registratie: December 2000
  • Laatst online: 16:37
Je hebt een paar problemen met de definitie hyperlink1....
Welke problemen? Geef eens wat meer info.

https://fgheysels.github.io/


  • BSeB
  • Registratie: Juni 2001
  • Laatst online: 22-09-2025
Het programma geeft de volgende info:

E:\My Documents\Visual Studio Projects\WindowsApplication11\Form1.cs(65): 'WindowsApplication11.Form1' does not contain a definition for 'button1_Click'

E:\My Documents\Visual Studio Projects\WindowsApplication11\Form1.cs(92): 'WindowsApplication11.Form1' does not contain a definition for 'HyperLink1'

E:\My Documents\Visual Studio Projects\WindowsApplication11\Form1.cs(93): 'WindowsApplication11.Form1' does not contain a definition for 'HyperLink1'

Dit snap ik dus even niet, want als ik in die helpfiel kijk staat daar het volgende:

HyperLink controls can render as text or as graphics.

To add a HyperLink control to a Web Forms page

Switch to Design view in the Web Forms Designer, and then drag a HyperLink control from the Web Forms tab of the Toolbox onto the page.
Specify the format of the link in the page by doing one of the following:
To create a text link, set the control's Text property. You can include HTML formatting in the property; for example, you can bold an individual word in the text by placing a <B> element around it in the Text property.
To create a graphical link, set the control's ImageUrl property to the URL of a .gif, .jpg, or other Web graphic file. For details about adding graphics to your project, see Adding and Removing Files in the File System Editor.
Note If you set both the ImageUrl and Text properties, the ImageUrl property takes precedence.
Set the NavigateUrl property to the URL of the page to link to.
Optionally, set the ID of a target window or frame to display the linked page in. You can either specify a window by name or you can use predefined target values such as _top, _parent, and so on.
Tip You can change the appearance of the link text — for example, whether it is underlined — using styles. For details, see Customizing the Appearance of ASP.NET Server Controls Using Styles.
The following example shows how you can set the properties of a Hyperlink control at run time. The method handles a Button control's Click event and sets the control's link text and target page.

' Visual Basic
Public Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Hyperlink1.Text = "Home"
Hyperlink1.NavigateUrl = "http://www.microsoft.com/net/"
End Sub

// C#
public void Button1_Click (object sender, System.EventArgs e)
{
this.HyperLink1.Text = "Home";
this.HyperLink1.NavigateUrl = "http://www.microsoft.com/net/";
}

Misschien dat ik in een verkeerde file an het kijken ben.

Edit: Ik vraag dus niet om een exacte oplossing, zoals de admins dadelijk weer suggeren, maar gewoon hoe ik dit wle moet aanpakken en waar ik misschien wle moet zoeken

[ Voor 7% gewijzigd door BSeB op 14-02-2003 14:49 ]


  • whoami
  • Registratie: December 2000
  • Laatst online: 16:37
Misschien kun je ook ff code-tags gebruiken als je code post, dat leest wat makkelijker.

Je hebt dus geen Button1OnClick event en eventhandler
Je hebt geen component met de naam hyperlink1 op je form (dat zal trouwens ook niet lukken denk ik, aangezien die Hyperlink component een webform component is)

Compiler errors interpreteren is ook een vak.

https://fgheysels.github.io/


  • BSeB
  • Registratie: Juni 2001
  • Laatst online: 22-09-2025
Als dit dus een webform component is hoe kan ik dan wle een hyperlink in mijn programma proppen?!

  • Woy
  • Registratie: April 2000
  • Niet online

Woy

Moderator Devschuur®
Gebruik maken van een LinkLabel

“Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.”

Pagina: 1