Any help will do!
I have a C# GUI which contain a User Control, this User Control contains a web browser, I want to make a button which will make it pop in a new window in the current state it is in.
Lets say I have the web browser opened on a specific page in Google, and I want to pop up the User Control in a new Windows Form at the same state and not as a new window that will take me to google.com but to the current page I had open.
Is there anyway to make it work?
Thanks in advance
Here is what you can do.
a) Access the UserControl class from the parent forms class.
b) Create a internal property in user control class that will return your WebBrowser control object.
c) From the main form you can then access WebBrowser.Url property and you either save this URL, redirect the browser or save the URL to show the user control later with the same URL. If you assign a string to this Url property it will navigate the browser to that page.
Please read this WebBrowser.Url MSDN
Related
I have 2 pages. LoginPage and ListPage.
In the LoginPage I ask for the credentials and the stores.
Then I see a list of information in ListPage.
What I want to get is that when I press the back button and capture the OnBackButtonPressed event, I want the application to hide and not return to the LoginPage page.
How can I do this?
Thank you very much for the help.
Instead of using NavigationPage you should directly be setting the MainPage for Navigation if you do not want to go back:
Application.Current.MainPage= new ListPage();
Or in the existing flow, you can close the current window in onBackPressed:
System.Diagnostics.Process.GetCurrentProcess().CloseMainWindow();
Or if you want to kill the process you can
System.Diagnostics.Process.GetCurrentProcess().Kill();
I'm trying to implement the login/register/forgot password flow for my first app in windows phone.
The idea main points of the result are:
The login form is accessible from many points of the app, when the user attempts to make an action that requires him to be logged in the system.
The login form must show the "register" option, showing a new screen with the register form
When the user closes the register form must return to the login form
A) I explored the Add/New Item menu in Visual Studio and the Content Dialog seems to be prepared for that functionallity, since its template xaml is a login screen. So I created a LoginDialog and a RegisterDialog from the ContentDialog template. Am I right?
B) The "sign in" button closes immediatly the Dialog, whats is the common pattern to make the user wait while the request is sent across the network and show the possible errors that may happen
C) How should I implement the navigation between ContentDialogs by the way I added a button to the LoginDialog:
private async void RegisterButton_Click(object sender, RoutedEventArgs e)
{
this.Hide();
await new RegisterDialog().ShowAsync();
}
How can I make the RegisterDialog to return to the Login dialog on close?
D) The dialog get closed when I press the Primary or Secondary button. How can I avoid it to close to show validation errors (like invalid password)
In my application I implemented it by putting both the Sign in option and the Register option on a MessageDialog, which is shown when the user tries to log in, so you don't need to put the Register option on the Sign in page.
I added separate pages, not content dialogs. I think it's a better approach, because this way if you get an error, the page won't "close", like a ContentDialog does, and you can handle the navigation very easily with simple GoBack and Navigate calls.
So I have a link I'm trying to click on a WebBrowser control. The problem is it pops up in a new tab, making IE open. I can't manage the web pages after it opens in IE, so I need to force it to somehow stay within my program. It doesn't matter if another WebBrowser control needs to open or anything, just so long as it says in my program.
there are a few ways you can do this, one way is to loop through the DOM (Document Object Model) and find the link which opens in a new window, and change its "target=" attribute value to "target=_top" this way it will open in current top-level page of your current WB Control container.
Otherwise, there is a NewWindow2 event which you can intercept, write the following code inside that event (where WB1 is you WebBrowser Controls name):
Processed = True
WB1.Navigate2 URL
This will tell your WB Control that the request has been processed (tricking it into believing that it has been processed), and if you just did this, nothing would happen, so after the first line you write the second line which tells it to open the URL that it just tried to open in the new window, in the current window (WB1), so really you are just reissuing the request but for the same container/WB Control where the link was clicked.
I've written the code in VB, however I'm sure it's not a problem to understand and transfer to c#.
Let me know how you get along and if there is anything else i can do to help.
I have a bunch of Custom Control Forms (i.e. login page, home page, etc.) that I want to be embedded within a "main form". Every time the user navigates to another page, only the content of the "main form" gets changed.
But the only way I can do this is to copy the contents of the Custom Controls and paste them into the "main form" - which is messy. Is there a standard way of doing this type of thing?
Update:
Ok it sounds like possibly you want to use an MDI form or maybe to use user controls (switching out controls for the new pages and such).
Old:
Is it possible you are talking about ASP.net pages and wanting to use master pages?
You might want to use a Panel. Put all the controls for each “embedded form” in a panel of its own. Then you can just show and hide the right panel to make controls appear and disappear.
Alternatively, if you want the user to be able to manually switch between the “pages”, you could consider using a TabControl.
I am creating console app, involving lots of services. I want to display a webpage within my program window. I know how to launch a new window ( http://dotnetpulse.blogspot.com/2006/04/opening-url-from-within-c-program.html )but I was wondering can I ask a browser to render a webpage withing my program window (in C#) ?
The best solution would likely be to use the WebBrowser control.
This can be placed on a form and allows the web page to appear inside your application.
Here is a nice example of how to go about implementing it http://ryanfarley.com/blog/archive/2004/12/23/1330.aspx
Hope this helps
Use the WebBrowser control and pass it the URL of the web page to render.
In your Windows form, something like (off the top of my head so may need tweaking to get it to compile):
WebBrowser browser = new WebBrowser();
browser.Dock = DockStyle.Fill;
this.Add(browser);
browser.Navigate("http://www.myurl.com");
In a Form you can use WebBrowser Control... in a Console Application there is no way wihout opening a new form.... but you could:
design a form with a Webbrowser Control
hide its border and showintask = false
Open it at a position in your Console-Window