Post to Facebook WP8 C# - c#

So I used this example
http://facebooksdk.net/docs/phone/howtos/publish-to-feed/
And when I tap the button I made, it shares a preset link. How do I change it to a textbox i have in the app?
And I use this code:
App.RootFrame.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
To redirect back to the mainpage after posting a message on facebook. but if i tap the back button, it goes back to the previous page i used to post a message. how do I fix it?

You might be better using the phones built in share api. That way the user can share with any social network they've connected to on their phone.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394009(v=vs.105).aspx
If you do need to do it the way you have then it sounds like you want to intercept the back button event.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.controls.phoneapplicationpage.backkeypress(v=vs.105).aspx

You could change the navigation stack with NavigationService.RemoveBackEntry(); after you have navigated away from the posting page.
Perhaps it is possible to run RemoveBackEntry() on the on posting pages OnNavigatedFrom event.

Related

Xamarin forms + prism login flow

I'm new in Xamarin Forms (and in Prism as well) I'm trying to create my first xamarin forms application and need a login flow.
I tried to check if user logged in application.OnInitialized method (and show Login or Main page depending on the result). But the problem is that if i show Login page and then after login i show Main page, then user is able to navigate to login page using hardware buttons..
Then i tried to check this in OnNavigationTo in Main page, but it's not working also. I checked this in PRE version and stable version and had different errors. In one of them the navigation just didn't work, in other - i got an error, that main page couldn't be created.
Then i tried to inject navigation service into MainPage (not a view model), but i found out that navigation service couldn't be injected there.
Then i decided to send a message from view after base.OnAppearing and subscribe to that message in view model and do navigation to login if needed as a callback. But there's one very strange problem. If i'm using ToolBarItems on a MainPage, then on windows phone it's disappearing after navigation back from login page (but suddenly, login page on windows phone HAS that toolbar items), Looks like OnAppearing method on windows phone fires before toolbar items are loaded. In any case, it's not a solution.
Then i decided to add a blank page and send a message after base.onAppearing into a view model and inside that view model i do redirect to Login or main page. So, it works with one small "BUT". If i press hardware back button on login page or main page i don't close application as i navigate to blank page which redirects me to login or main page.
Is there a proper way to implement login flow using prism? i really like it as it's very powerful framework..
Thanks in advance!
Keep in mind that OnNavigatedTo only works when using the latest preview version, and calling NavigationService.Navigate. There are a couple of approaches to take here. First you can navigate to MainPage, then check in the OnNavigatedTo. If not logged in, navigate to the LoginPage. You could also just check on App startup. When you show the LoginPage, you can use an absolute URI to replace the entire navigation stack. Essentially what this does is set MainPage = new MainPage().

Click "Send" button of G-Mail programmatically

I am creating an Email Sending Software. So far i am able to open chrome and fill the details of the email (subject,body,attachments and all) but i wanted to know is there any way i can click Send button of G-Mail programmatically too?
Code for filling details in chrome
Process ps = Process.Start("chrome.exe", "https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=1&to=a#gmail.com&bcc=b#gmail.com);
Note I haven't used SmtpClient to send email because it was not fulfilling my customized requirement (sorry cannot disclose the reason).
The way you want this, is not possible. Process.Start opens a new Process. In this case it opens Google Chrome, with the URL you sent with it. This URL contains a querystring containing the subject and the body of the email. This is possible, because Google reads this on the server-side, and puts it in the right fields. There is no way to enter the send button though. This is a POST action, which can not be triggered by a URL.
C# form, does have a WebBrowser class. From here you can access buttons and click them, but I don't think Google will allow this, and most likely send you a captcha. (That is, if you manage to login in the first place.)
I can't help with the simulated button press you're looking for, but I can suggest that you rather try to use the Gmail API to do what you're trying to do:
https://developers.google.com/gmail/api/?hl=en
This would be a more reliable and stable way to send gmail programmatically, and you still don't have to use the smtp object directly.
You should probably use Selenium (WebDriver). It allows you to control browser from c# code, navigates pages, traversing DOM etc..

A popup notification balloon after comment reply in asp.net

Now I am doing a forum like website. I wan to do something like after the member reply the post and the homepage will display a popup notification balloon and show out the number of notification that the member are unread. May I know how can I make it? I am using asp.net and C# in my website.
You can use the PopupControl in AJAX:
<ajaxToolkit:PopupControlExtender ID="PopEx" runat="server"
TargetControlID="DateTextBox"
PopupControlID="Panel1"
Position="Bottom" />
Here is a link that explains it further.
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/PopupControl/PopupControl.aspx
It sounds like you need to enable communication across browser sessions. For something like this I'd suggest SignalR http://www.asp.net/signalr.
It allows you to use javascript to broadcast messages and listen for messages sent from the server. You can also hook into it via code behind. So, say user X responds to user Y's post. After you do what you need to do to save the post to the database, you add a bit of code that broadcasts to user X "Hey! Someone commented on your post. Check it out!".

WP8 Back Button between applications

I have an application on Windows Phone 8 that opens a link on Internet Explorer.
The page loads until the end and when I want to go back to the application, Internet Explorer blocks and does not return.
This is my code to open the link in Internet Explorer.
text.NavigateUri = new Uri(url, Urikind.Absolute);
Why does this happen?
I think you'll want to do something like this:
//After your page has finished loading
NavigationService.Navigate(new Uri(url, Urikind.Absolute));
This isn't entirely clear from your question though. Do you want to go back to the application after the user has clicked on something in the web page or simply after the page is done loading? Either way you'll want to handle that event then call the line above.

How to open a new window without refresh?

I have this code implemented in my application, but whenever i click onto the link, it do help me open a new window. But the original page was "refresh", it kept go all the way back to the top. How can i resolve this problem?
code:
Response.Write("<script>window.open('" + url + "')</script>");
As I understand it, each time you click the link the page is being send to the server where the event is handled (with some C#). If you do that, the server will send the whole page back.
You probably want to control this on client side, with some Javascript.
That said, what you are problably looking for is the attribute target of the link:
something
That will tell the browser that you want to open another tab or windows when the user click the link, and then there request the page specified by url in that tab or window.
Sounds like you want Response.Redirect(myURL)
When you click on the link and handle it in the code behind, that means the link is run at the server side, so it has to post back, which makes it look like it's "refreshing", but it's actually posting back.
You need to handle the opening of the new window on the client's side via Javascript.
If your're writing this to your page, this will redirect you to the url you want
Response.Write("<script>;location.href='" + url + "'</script>");

Categories

Resources