473,473 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Page not updating after Login control authenticates


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>
May 16 '06 #1
3 2107
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>

May 16 '06 #2
rjl
try using if(!ispostback) check around the object creation in the load.

May 16 '06 #3
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.

May 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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...
0
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...
2
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...
0
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...
0
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...
13
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?...
6
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...
7
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...
4
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.