How can I implement a UIwebView for IOS in VisualStudio using Xamarin.IOS and C#?
I can create the webView in the Storyboard but how can I define the URL?
And how can I get the current Url?
Click on the webview after adding a webview in the storyboard, then the Properties will show at the right-bottom of VS like this:
Add the Name as the screenshot shows, press the Enter. Now you can load a URL for the WebView in your .cs file like this:
NSUrl url = NSUrl.FromString("https://www.google.com");
NSUrlRequest urlRequest = NSUrlRequest.FromUrl(url);
webView.LoadRequest(urlRequest);
To get the current url of the webview when it already has loaded a URL via the code:
webView.Request.Url.AbsoluteString;
Related
I have a C# WinForms application which I need to open a url through it.
The actual task is to display a web page without all it's functionality (changing url/go back button/etc...), do some actions in that site and then retrieve information from it according to what the user entered/did in that site.
Iv'e already tried the WebBrowser option, but it's opening the url site in a browser with all of it's functionality:
System.Windows.Forms.WebBrowser WebBrowser1 = new System.Windows.Forms.WebBrowser();
WebBrowser1.Navigate(new Uri("https://stackoverflow.com/questions/59766190/open-a-url-site-in-a-winforms-window-and-not-from-the-browser"), true);
WebBrowser1.BringToFront();
Any ideas?
Thanx :)
You're passing true as the second argument to the Navigate(Uri url, bool newWindow) method, which specifies that it should open the url in a new window (see the Microsoft documentation).
Changing your code so that it passes false for the newWindow argument will cause the url to be opened in the WebBrowser control instead (you also need to add the control to the form's Controls collection):
System.Windows.Forms.WebBrowser WebBrowser1 = new System.Windows.Forms.WebBrowser();
this.Controls.Add(WebBrowser1);
WebBrowser1.Navigate(new Uri("https://stackoverflow.com/questions/59766190/open-a-url-site-in-a-winforms-window-and-not-from-the-browser"), false);
I'm successfully navigating from www.url1.com to www.url2.com using webbrowser control but iam unable to get the url of navigated page i.e., www.url2.com, using Webbrowser control in asp.net web application.
If you have any solution regarding this issue please share with me.
Thanks in advance.
The following code is to navigate the WebBrowser control to a specific URL
this.webBrowser1.Navigate("http://www.google.com");
String Path = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).OriginalString;
String rootDirectory = Path.Substring(0, LastIndexOf("/"));
I need convert the image that is in String or Byte to Icon to show in ToolbarItems.
I need show the photo from user in right side from menu of the app.
My code until now:
this.ToolbarItems.Add(new ToolbarItem("name", "icon", () =>
{
}, ToolbarItemOrder.Primary));
If i set an icon from project, him show me like this:
It seems that ToolbarItem in Xamarin.Forms can only use local files (app resources).
See the API documenation - the property is a FileImageSource, which can only take a local file path.
I'm trying to make a custom web page and put it in a webview in Xamarin using C#
What I have is a UIViewController containing a UIWebView.
In my project I have a folder like this:
Project
Content
index.html
js
css
But when I try to load the index.html file into the webview nothing happens.
I tried just loading an external webpage and it works fine.
this is my code for loading the content in the ViewDidLoad method of the UIViewController:
string fileName = "Content/index.html";
string localHtmlUrl = Path.Combine(NSBundle.MainBundle.BundlePath, fileName);
MyWebView.LoadRequest(new NSUrlRequest(new NSUrl(localHtmlUrl, false)));
MyWebView.ScalesPageToFit = true;
I think it has something to do with the page not finishing it's loading, but I can't figure out how to do this properly.
Derp, always make sure to set the 'Build Action' on your file to BundleResource on each file to include them in the build by right clicking on them...
I am making a windowsphone silverlight App for windowsphone OS 8. I am Using windowsphone user controls where I make changes dynamically.
My question is just like the way we create an instance of a phoneApplication Page for Normal .xaml Page using NavigationService.Navigate("Source Uri with unique GUID") . How can I achieve the same effect for a windowsphone User Control Page where I make my dynamic changes to update as there is no Navigation Service.Navigate() method available. ?
Currently I have to Navigate like UserControl-Page-UserControl
When you want to Navigate from a page, you can use NavigationService.Navigate().
When you want to Navigate from a UserControl, You can use the PhoneApplicationFrame to navigate.
Code Sample:
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/MyProjectName;component/MyFolderName/MyPage.xaml", UriKind.Relative));
You need to append a GUID when you want to navigate to a new instance of the same page which you are currently residing.