I just started the design of an ASP.NET application which accesses one of
our custom web services to provide user authentication, among other
purposes.
I created a log-in page (code below), using the WebControls.Login control.
I put a simple label on the page, to display text showing whether the log-in
was successful. I populate the Label.Text from within the event handler for
the Login control's Authenticate event.
But when I run the page, the label text never shows up on the page. When I
singe step in the debugger, the Label.Text is definately set, but when the
web page is refreshed (after exiting the event handler) the Label text does
not show up on the web page.
I'm new to ASP.NET 2.0, and I assume I am confusing some aspect of the
page/postback lifecyle. Clarifications or recommendations would be greatly
appreciated.
Thanks, Bruce
---------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using com.myservice;
public partial class _default : System.Web.UI.Page
{
com.myservice.ReflectionServer m_Server;
com.myservice.UserElements m_user;
protected void Page_Load(object sender, EventArgs e)
{
m_Server = new com.myservice.ReflectionServer();
}
protected void login_Authenticate(object sender, AuthenticateEventArgs e)
{
com.myservice.ReturnData result = new ReturnData();
string userName = login.UserName;
string passWord = login.Password;
result = m_Server.IsAuthenticated(userName, passWord);
if (result.Success)
{
e.Authenticated = true;
labelLogInResult.Text = "Successful Log In";
login.Enabled = false;
m_user = new UserElements();
m_user.userName = userName;
m_user.passWord = passWord;
Application["user"] = m_user;
}
else
{
login.FailureText = "Invalid Username/Password";
labelLogInResult.Text = "Invalid Username/Password";
e.Authenticated = false;
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs"
Inherits="_default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body style="font-size: 12pt">
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Image ID="Image1" runat="server" Height="161px"
ImageUrl="~/images-local/060508-reflection.jpg"
Width="320px" /><br />
<asp:Login ID="login" runat="server" BackColor="#F7F6F3"
BorderColor="#E6E2D8" BorderPadding="4"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
Font-Size="0.8em"
ForeColor="#333333" style="left: 319px; position: absolute; top:
232px"
OnAuthenticate="login_Authenticate" >
<TitleTextStyle BackColor="Navy" Font-Bold="True"
Font-Size="0.9em" ForeColor="White" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775"
/>
</asp:Login>
<br />
<strong><span style="font-family: Tahoma; color: darkred;">User
Tasks</span></strong><br />
<br />
<span style="font-size: 11pt; font-family: Tahoma">
Create/Modify User Account<br />
Create/Remove/Modify Item<br />
</span>
<br />
<br />
<strong><span style="font-family: Tahoma; color: darkred;">
Administrator Tasks</span></strong><br />
<br />
<span style="font-size: 11pt; font-family: Tahoma">
View Raw Table Contents<br />
Remove a User<br />
Remove an Item</span><br />
<br />
<asp:Label ID="labelLogInResult" runat="server" style="left: 322px;
position: absolute; top: 384px" Height="160px"
Width="203px"></asp:Label></div>
</form>
</body>
</html> 3 2099
I can let you know about the new fast and easy way to get confirmation of
output string data by using Page.Title = "value"; which means no more need
for proxy controls or using Response.Write when running the Look and See
Visual Debugger :-).
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Bruce" <co*********@newsgroup.nospam> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl... I just started the design of an ASP.NET application which accesses one of our custom web services to provide user authentication, among other purposes.
I created a log-in page (code below), using the WebControls.Login control. I put a simple label on the page, to display text showing whether the log-in was successful. I populate the Label.Text from within the event handler for the Login control's Authenticate event.
But when I run the page, the label text never shows up on the page. When I singe step in the debugger, the Label.Text is definately set, but when the web page is refreshed (after exiting the event handler) the Label text does not show up on the web page.
I'm new to ASP.NET 2.0, and I assume I am confusing some aspect of the page/postback lifecyle. Clarifications or recommendations would be greatly appreciated.
Thanks, Bruce
---------------------------------------------
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
using com.myservice;
public partial class _default : System.Web.UI.Page { com.myservice.ReflectionServer m_Server; com.myservice.UserElements m_user;
protected void Page_Load(object sender, EventArgs e) { m_Server = new com.myservice.ReflectionServer(); }
protected void login_Authenticate(object sender, AuthenticateEventArgs e) { com.myservice.ReturnData result = new ReturnData(); string userName = login.UserName; string passWord = login.Password;
result = m_Server.IsAuthenticated(userName, passWord); if (result.Success) { e.Authenticated = true;
labelLogInResult.Text = "Successful Log In"; login.Enabled = false;
m_user = new UserElements(); m_user.userName = userName; m_user.passWord = passWord; Application["user"] = m_user; } else { login.FailureText = "Invalid Username/Password"; labelLogInResult.Text = "Invalid Username/Password"; e.Authenticated = false; }
} } <%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body style="font-size: 12pt"> <form id="form1" runat="server"> <div> <br /> <br /> <asp:Image ID="Image1" runat="server" Height="161px" ImageUrl="~/images-local/060508-reflection.jpg" Width="320px" /><br /> <asp:Login ID="login" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#333333" style="left: 319px; position: absolute; top: 232px" OnAuthenticate="login_Authenticate" > <TitleTextStyle BackColor="Navy" Font-Bold="True" Font-Size="0.9em" ForeColor="White" /> <InstructionTextStyle Font-Italic="True" ForeColor="Black" /> <TextBoxStyle Font-Size="0.8em" /> <LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" /> </asp:Login> <br /> <strong><span style="font-family: Tahoma; color: darkred;">User Tasks</span></strong><br /> <br /> <span style="font-size: 11pt; font-family: Tahoma"> Create/Modify User Account<br /> Create/Remove/Modify Item<br />
</span> <br /> <br /> <strong><span style="font-family: Tahoma; color: darkred;"> Administrator Tasks</span></strong><br /> <br /> <span style="font-size: 11pt; font-family: Tahoma"> View Raw Table Contents<br /> Remove a User<br /> Remove an Item</span><br /> <br /> <asp:Label ID="labelLogInResult" runat="server" style="left: 322px; position: absolute; top: 384px" Height="160px" Width="203px"></asp:Label></div> </form> </body> </html>
try using if(!ispostback) check around the object creation in the load.
I think I've found the explaination. The line "e.Authenticated = true;",
which tells the Login control that authentication was successful, triggers a
full page reload (and not a postback). As a result, the Label control is
reset to its initial state upon the reload (thus removing the "Successful
Log In" text I had assigned to it.
I'm set. Thanks for the answers.
-- Bruce
"rjl" <rj****@hotmail.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com... try using if(!ispostback) check around the object creation in the load. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul |
last post by:
Title: What are the Consequences of Aspx page separate from app DLL
Hi JL;
I am working on a big asp.net application.
When we migrate the dll (or dlls) to the production server, all users
who are...
|
by: itsharkopath |
last post by:
Hi,
Imagine a user in a hotspot, when he comes to the hotspot and tries
to load a webpage (on the internet), he would automatically redirected
to login page.
I believe the following is to be...
|
by: nvv via DotNetMonster.com |
last post by:
Hi,
I am working on a web site which authenticates an user using forms. And once they logout, I observed that, for any reason if they click on "BACK" button of the browser, the user is being taken...
|
by: Joe Rigley |
last post by:
Hi,
I'm a little new to ASP Dotnet, but have been coding in classic ASP for over
5 years...
I'd appreciate some suggestions/guidance in writing an Intranet login page
that authenticates...
|
by: Jonathan Duke |
last post by:
I have written a custom session state provider that stores session data in
XML in a SQL database , and I was running the SQL profiler to
verify that all of my stored procedures were called in the...
|
by: Michael |
last post by:
I have setup a public variable in the Master Page "code-behind-file". Now I
would like to set that value from the UserControl, but I can't seem to find a
way to do this. Does anyone have any ideas?...
|
by: BizWorld |
last post by:
Hi,
I have a scenario where i need to configure only Login.aspx page to use
SSL. All other application will run on HTTP protocol. If someone can
guide me how to accomplish this. One of my idea...
|
by: Andy B |
last post by:
I have a class I am creating for data access. I need to access controls from
inside the class that are on a particular page. How do I do this? or is
creating an instance of the page class and using...
|
by: kimiraikkonen |
last post by:
Hi,
Just to test, i placed a simple webbrowser to login a site, this site
has no problems and has same error with IE6 SP2 but it's suppressed as
well and no problem with Firefox browser, but using...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
| |