asp login - open a new window if authentication is successful - asp.net

I need to open a new window if the authentication of a users login is successful. is there an easy way to have the DestinationPageUrl open in a new window using something like target="_blank" ? below is my code:
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="Login1" runat="server" DestinationPageUrl="~/Public/Index.aspx" OnAuthenticate="Login1_Authenticate">
</asp:Login>
</AnonymousTemplate>
<LoggedInTemplate>
Welcome User
</LoggedInTemplate>
</asp:LoginView>
<br />
</div>
</form>
</body>

I would code the page with two controls, one for login. Once the login is successful, hide the login and display your form. No redirect necessary.

Related

call login page and register page in popup window in asp.net

i have to design an website use asp.net
in this web site we have to use login and register
i use this code in master page
<asp:LoginView ID="Log_view" runat="server">
<AnonymousTemplate >
<span class="log_txt">Hi Guset! </span>
Rigster
Login
</AnonymousTemplate>
<LoggedInTemplate>
<asp:LoginName ID="Log_name" runat="server" CssClass="log_txt" FormatString="Hi, {0}!"/>
<asp:LoginStatus ID="LoginStatus1" runat="server" LogoutText="Logout" CssClass="log_lnk" LogoutPageUrl="~/Default.aspx" LogoutAction="Redirect" OnLoggingOut="LoginStatus1_LoggingOut" /> </LoggedInTemplate>
</asp:LoginView>
and its work without any problem, but the login page and register page will display normal, i want to display in popup window.
in other page i use this script to call page in popup window use AjaxControlToolkit and its work fine
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<span>
<a href="#" id="Rig_log" runat="server" > Rigister | Login </a>
</span>
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" TargetControlID="Rig_log" CancelControlID="btn_close" BackgroundCssClass="popup_Background">
</cc1:ModalPopupExtender>
<cc1:DragPanelExtender ID="Image1_DragPanelExtender" runat="server"
Enabled="True" TargetControlID="Panl1" DragHandleID="Panl1">
</cc1:DragPanelExtender>
<asp:Panel ID="Panl1" runat="server" CssClass="Popup" align="center" style = "display:none">
<div id="popup_header"> <span>Register | Login </span><a href="#" ID="btn_close" runat="server" > X </a></div>
<div id="popup_content"> <iframe id="irm1" src="Register_login.aspx" runat="server"></iframe></div>
</asp:Panel>
my issue is , how i can call login page and register page in popup, i try but it's not working
thanks
Hanashi,
You can try out java script below like this.
window.open(your page name);
Dinesh Nagrale

A page can have only one server-side Form tag Issue

I have a masterpage like this
<%# Master Language="C#" MasterPageFile="~/masterpages/XmasShop.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="cphContents" runat="server">
<asp:LoginView runat="server" ID="lview1">
<LoggedInTemplate>
<div class="confirmation-cantainer">
<div class="confirm-01">
<form runat="server">
<umbraco:Macro Alias="[Xmas]ShopConfirm" runat="server"></umbraco:Macro>
</form>
</div>
</div>
</LoggedInTemplate>
</asp:LoginView>
</asp:Content>
<asp:Content ContentPlaceHolderID="cphAuthenticationPane" runat="server">
<asp:LoginView runat="server" ID="lview12">
<LoggedInTemplate>
<form runat="server">
<asp:LoginStatus ID="lslougout" runat="server" Style="float: right; color: #003263; text-decoration: none;" text="Logout"></asp:LoginStatus>
</form>
</LoggedInTemplate>
</asp:LoginView>
</asp:Content>
And you can see I have two form tags in it,but both are seperate not nested.Still I am getting an error
A page can have only one server-side Form tag.
Can any one suggest me a solution.When I tried to remove one of the forms its throwing an error elements must be inside a form tag and when I add form above error.
Use the following tutorial to set up two form tags and be able to toggle them on and off, as required:
http://jerschneid.blogspot.com/2007/03/hide-form-tag-but-leave-content.html
One solution is to have the login information on a separate page. You could also look into using an iframe.
This error occurred due to use of more than one
<form runnat="server">
tag.
Remove one of the form tag.
This would be more clear by visiting this link

asp.net web service login

I have a login system using forms authentication, the problem is I want login and register links if the user is not logged in and if the user is logged in I want welcome username and a logout link. My website is using master page for a consistent layout so I am assuming all the code will go in there..
I am thinking on the page load I will have something like this:
if (User.Identity.IsAuthenticated)
{
label1.Text = User.Identity.Name;
}
But I get user does not exist in the current context.
Thanks
Thanks to filbert. Here is the answer:
<asp:LoginView ID="RegisterLink" runat="server">
<AnonymousTemplate>
<div class="titleRegistration">
Register or
</div>
</AnonymousTemplate>
<LoggedInTemplate>
<div class="titleRegistration">
Hi <b><asp:LoginName ID="LoginName1" runat="server" />!</b>
</div>
</LoggedInTemplate>
</asp:LoginView>
<asp:LoginStatus ID="lsGeneral" runat="server" LogoutPageUrl="/Users/Logout.aspx" />
Thanks Filbert.

Client ID is not getting generated for asp.net controls

I am writing a simple webform on .net 4.0 framework.
<body>
<form id="form1" runat="server">
<div>
<span>Name</span>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</div>
<div>
<span>Email</span>
<asp:TextBox ID="txtEmail" EnableViewState="false" runat="server"></asp:TextBox>
</div>
<div>
<asp:Button ID="btnButton" runat="server" Text="Submit" />
</div>
</form>
</body>
Issue is when the form renders on browser, I am not getting ClientID for the server side controls. This is strange for me.
The portion of the markup in the browser is
<div>
<input type="submit" name="btnButton" value="Submit" id="btnButton" />
</div>
Notice there is no clientID.
Edit : Client ID something like 'ctl00$MasterPageBody$ctl00$btnButton2'
The client id of the button is btnButton. The other one "ctl..." is when you have your control inside a masterpage. As a side not: If you don´t wan´t asp.net changing your id:s you can set clientidmode='static'.
ClientID is a server side attribute.
You would see the ClientID on the client as the ID attribute:
id="btnButton"
Client id is calculated on the server, it never gets sent to the client.
You need runat="server" to generate a client ID for the control for the reasons mentioned

How can I add an invitation dialog to my facebook application (using ASP.Net)

I'm developing a facebook application, using IFrame instead of FBML. I have a main page with a sub-iFrame inside. In the inner iframe (the invitation page) I have:
<%# Register Assembly="Facebook.Web" Namespace="Facebook.Web.FbmlControls" TagPrefix="cc1" %>
<cc1:Fbml ID="Fbml1" runat="server" Xfbml="True">
<ContentTemplate>
<cc1:RequestForm ID="RequestForm1" runat="server" Method="Post" Type="Xfbml" Xfbml="True"
Invite="True" Content="Invite your friends" Action="." Visible="True">
<ContentTemplate>
<cc1:MultiFriendSelector ID="MultiFriendSelector1" runat="server" Rows="3" Xfbml="True"
ShowBorder="True" EmailInvite="True" Bypass="Cancel" ActionText="Select Friends you want to invite">
</cc1:MultiFriendSelector>
</ContentTemplate>
</cc1:RequestForm>
</ContentTemplate>
</cc1:Fbml>
This doesn't work at all and when I view the frame source, I get:
<fb:fbml>
<fb:request-form type="Xfbml" Content="Invite your friends" action="." method="POST">
<fb:multi-friend-selector actiontext="Select Friends you want to invite" showborder="true" email_invite="true" rows="3" bypass="cancel"></fb:multi-friend-selector>
</fb:request-form>
</fb:fbml>
Any ideas and/or suggestions are very appreciated. Thanks for reading anyway

Resources