How to navigate to Facebook page in asp.net - asp.net

I created my own site and my own Facebook page.
I add follow me button on site.
in that user have to follow me either on facebook or on twitter.
Problem: How to navigate user to first login page and then after successfull login to my facebook page

Place image and navigate to login page on image click like following:-
<asp:Button ID="imgbtnFaceBook" CausesValidation="False" runat="server" OnClick="imgbtnFaceBook_Click"/>
protected void imgbtnFaceBook_Click(object sender, EventArgs e)
{
Response.Redirect("yourLoginPageLink");
}
On login page check credentials and redirect to facebook page like following:-
protected void btnLogin_Click(object sender, EventArgs e)
{
// check login Credentials
Response.Redirect("yourFaceBookPageLink");
}
<asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />

<asp:Button ID="imgbtnFaceBook" CausesValidation="False" runat="server" OnClick="imgbtnFaceBook_Click"/>
protected void imgbtnFaceBook_Click(object sender, EventArgs e)
{
Response.Redirect("https://www.facebook.com/yourPageLink");
}

Related

Asp.net Validations and controls

how to disable the (Required attribute) in Text box in ASP.NET web forms
I want to change the web form page to another one when I click on the Login button but I cant!
please help!
For Disable Validation :
<asp:TextBox id="txt" runat="server" causesvalidation="false" /> // or reqiured=false
For Redirect :
protected void btnConfirm_Click(object sender, EventArgs e)
{
Response.Redirect("YourPage.aspx");
//or
Server.Transfer("YourPage.aspx");
}

Adding back codes to hyperlink in asp

I have first this
<li><asp:HyperLink id="logoutBtn" NavigateUrl="login.aspx" Text="Logout" runat="server"><i class="fa fa-sign-out fa-fw"></i> Logout </asp:HyperLink></li>
But I think it goes first to the page before he runs the back code which is this.
public void logoutBtn_Click(object sender, EventArgs e)
{
Session.Clear();
Response.Redirect("../login.aspx");
}
So basically I can still access any site because the Session is not cleared.
How can I achieve that whenever I click the HyperLink the code is fired?
The purpose of a hyperlink is to navigate the user to another destination. (Plus, you don't have a click eventhandler attached to you hyper link, that will run your code behind.)
If you want to run server-side code use a good old button:
<asp:Button ID="logoutBtn" runat="server" onclick="logoutBtn_Click" Text="Logout" />
public void logoutBtn_Click(object sender, EventArgs e)
{
Session.Clear();
Response.Redirect("../login.aspx");
}
If you want to use an asp:Hyperlink control to logout the user, navigate him to a specific logout page:
<li><asp:HyperLink id="logoutBtn" NavigateUrl="logout.aspx" Text="Logout" runat="server"><i class="fa fa-sign-out fa-fw"></i> Logout </asp:HyperLink></li>
Create the logout.aspx page and in the Page_Load event, log the user out:
protected void Page_Load(object sender, EventArgs e)
{
Session.Clear();
Response.Redirect("../login.aspx");
}

Need to stop Page validations while Implementing Logout

while implementing Logout event Page validation events were raising in My form and It stops Firing Logout Method
Need to stop page validation events when I call Logout Method using on ServerClick()
<li><span>Logout</span></li>
My Code :
protected void logout_ServerClick(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
Session.Abandon();
Session.Clear();
Session.RemoveAll();
Response.Redirect("Login.aspx");
}
use CausesValidation="False"
<asp:LinkButton id="logout" runat="server" Text="logout" CausesValidation="False"> </asp:LinkButton>

transfer listbox items from one asp.net page to another using session

Transfer listbox items from one asp.net page to another using session. I want to transfer the items of a list box from one asp.net page to another. The code somehow is throwing error. The items in the listbox are not being retrieved either. I want to do the same with a check box list. Hopefully the listbox issue will help[ me solve that too. Please advice.
First Page
<asp:ListBox ID="SelectedItems" runat="server" SelectionMode="Multiple"/>
<asp:Button ID="sbmtButton" runat="server" Text="Submit" Width="152px" OnClick="sbmtButton_Click" />
.cs for the First Page
protected void sbmtButton_Click(object sender, EventArgs e)
{Session["wrd"] = SelectedItems;Server.Transfer("~/aftrSubmit.aspx";);}
Second Page
.cs for the Second Page
protected void Page_Load(object sender, EventArgs e)
{if (!this.IsPostBack){Prescription_list = (ListBox)Session["wrd"];}}
First Page ASPX Code:
<asp:ListBox ID="SelectedItems" runat="server" SelectionMode="Multiple">
<asp:ListItem Text="A"></asp:ListItem>
<asp:ListItem Text="B"></asp:ListItem>
<asp:ListItem Text="C"></asp:ListItem>
</asp:ListBox>
<asp:Button ID="sbmtButton" runat="server" Text="Submit" Width="152px" OnClick="sbmtButton_Click" />
First Page C# Code-Behind:
protected void sbmtButton_Click(object sender, EventArgs e)
{
ListItem[] x = new ListItem[SelectedItems.Items.Count];
SelectedItems.Items.CopyTo(x, 0);
Session["wrd"] = x;
Server.Transfer("~/aftrSubmit.aspx");
}
Second Page ASPX Code:
<asp:ListBox ID="Prescription_list" runat="server" SelectionMode="Multiple"/>
Second Page C# Code-Behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
ListItem[] x = (ListItem[])Session["wrd"];
Prescription_list.Clear();
Prescription_list.Items.AddRange(x);
}
}

how to change the iframe by a buttonclick in asp.net?

i have a homepage and it has a iframe..i want that after clicking the button sign in..the particualr iframe will have the user.aspx..but how to implement this in code behind of the user.aspx.cs on buttonclick?? i want work it for server side...and i have learnt that javascript function can't be used as i am wanting it in server side..
my asp button and iframe in home.aspx
<asp:Button runat="server" ID="signin" CssClass="signinbt" Text="Sign in" OnClick="signin_Click"/>
</div>
<iframe id ="iframestyle" src="homeframe.aspx" name="iframe_a" runat="server" style="margin-top:0px;width:100%;height:500px;"></iframe>
</div>
my codebehind
protected void signin_Click(object sender, EventArgs e)
{
iframstyle.Attributes["src"] = "userpage.aspx";
}
here showing that iframestyle doesn't contain in the present context..
try This
protected void btnChange_Click(object sender, EventArgs e)
{
iframestyle.Attributes["src"] = "homeframe.aspx"
}

Resources