In ASP.net C# is there a way I can pass control to my CS from Javascript? -


I am trying to implement Facebook login in my application as per following this guide:

The Facebook stuff are all working fine :)

However after the completion of Facebook authentication, I will be redirected to the next part of the sign up before entering the webpage I want to pass all the appropriate variables in the C # code process.

I know how to use HTML tags like HTML tags:

  & lt; Asp: ImageButton id = ctrlNext runat = "server" imageUrl = "Btn_Next.gif" onclick = "ctrlNext_Click" & gt; & Lt; / Asp: ImageButton & gt;  

But if there is currently control within a javascript function after the completion of Facebook - then I do not want the user to manually click on a button to continue - Ideally they click the Facebook login button, call the Facebook API, and then redirect the page to store the information.

Make sure to include the following by using the statement:

  using System.Web.Services;  

Your page method will look something like this:

  [WebAmid] public static string fbLogin () {/ * What to do with your DB magic? / Code>  

Use the jQuery.ajax method:

  FB.login (function (feedback) {if (response.status === 'connect') { // in your app and facebook .jax ({type: "post", url: "youPageName.aspx / fbLogin", data: "{}", content type: "app / jason; charset = utf-8" , Datatype: "jsan", success: function (msg) {// something interesting here // like a redirect document. Location.href = "http://www.somewherecool.com/newPage.aspx";}})}} Else if (response.status === 'not_authorized') {/ / Person is logged into Facebook, but your app is not.) Else {// is not logged in Facebook, so we are not sure if they are logged into this app or not.}});  

To start you, these are just bare bones. Do not forget to deal with the error etc.

However

As you are going to redirect, you can beat the type of purpose AJAX is going to post back to the page There are some ways to use JavaScript for the fastest, easiest and fastest way to do this, with A normal server click handler, ASP button which is hidden through CSS. To use the button, use javascipt (jquery) in the following example.

Button

  & lt; Asp: ImageButton id = "ctrlNext" Style = "display: none" runat = "server" imageUrl = "Btn_Next.gif" onclick = "ctrlNext_Click" & gt; & Lt; / ASP: ImageButton & gt;  JavaScript   {// Log in to your app and Facebook. Click on the // button ("# & lt;% = ctrlNext.ClientID%>"). Click ();} and if (response.status == = 'Not_authorized') {// People are logged into Facebook, but your app is not.} Else {// is not logged in Facebook, so we are not sure that // if they are logged into this app or No.}});  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -