3
votes

I am trying to set the Text property of a TextBox to the Url property of a WebBrowser. The code I have is:

textBox1.Text = webBrowser1.Url;

Visual Studio says:

"Cannot implicitly convert type System.Uri to string"

How do I set the textBox1.Text property to the value of the webBrowser1.Url?

2
There are no attributes in the code shown... Are you sure you were planning to ask about attributes and not about properties for example? - Alexei Levenkov

2 Answers

1
votes

You just need to call the ToString method:

textBox1.Text = webBrowser1.Url.ToString();
1
votes

The webBrowser1.Url is of type System.Uri. To assign it to textbox, which is oftype string you can simply do a webBrowser1.Url.ToString() or use in-built properties like AbsoluteUri, OriginalString etc. depending on your requirement. For complete list of properties refer this MSDN link.