I've have a webapplication with a Masterpage, and inside the page you have Default page,
I've problem with aupostback by login user/password. The Login-page is a usercontrol who placed in a Placeholder (inside the Default-page). The button btnLogin is placed on the default page.
When I click on the Login-button, I only see the DoTextChanged-event will fire and the Login-page has get the default settings again.
<asp:RequiredFieldValidatorID="valIsGebruikerOpgegeven"runat="server"ErrorMessage="De
gebruikersnaam is niet opgegeven." CssClass="FailureNotification"Text="*"ControlToValidate="txtGebruiker"SetFocusOnError="true"/>
<asp:RequiredFieldValidatorID="valIsWachtwoordOpgegeven"runat="server"ErrorMessage="Het
wachtwoord is niet opgegeven." CssClass="FailureNotification"Text="*"ControlToValidate="txtWachtwoord"SetFocusOnError="true"/>
When I remove the AutoPostback="true", then the Login works fine. But when I Logout a I returns back to the Login page. The Login doesn't work anymore.
What do I wrong? The Login has to do work always correct. Also when you want to login on another username.
I'm not sure why you would like to seperate the login button rather than merge them as a web user control. However, you can try to test my code below and change it depends on your requirement. I create all files in a folder named CustomerControl.
WesleyN
Member
1 Points
8 Posts
OnTextChanged and the events by clicking on Submit-button doesn't work fine
Aug 31, 2012 09:32 AM|LINK
I've have a webapplication with a Masterpage, and inside the page you have Default page,
I've problem with aupostback by login user/password. The Login-page is a usercontrol who placed in a Placeholder (inside the Default-page). The button btnLogin is placed on the default page.
When I click on the Login-button, I only see the DoTextChanged-event will fire and the Login-page has get the default settings again.
in uclLogin.ascx
in uclLogin.ascx.cs
in the default.aspx:
When I remove the AutoPostback="true", then the Login works fine. But when I Logout a I returns back to the Login page. The Login doesn't work anymore.
What do I wrong? The Login has to do work always correct. Also when you want to login on another username.
thanks
SohailShaikh
Contributor
6119 Points
1167 Posts
Re: OnTextChanged and the events by clicking on Submit-button doesn't work fine
Aug 31, 2012 09:53 AM|LINK
On Change Event loss your password so please remove onchange event from this text box
Sohail Shaikh
WesleyN
Member
1 Points
8 Posts
Re: OnTextChanged and the events by clicking on Submit-button doesn't work fine
Aug 31, 2012 11:11 AM|LINK
How can the system do remember the password and username?
SohailShaikh
Contributor
6119 Points
1167 Posts
Re: OnTextChanged and the events by clicking on Submit-button doesn't work fine
Aug 31, 2012 11:44 AM|LINK
you can call this on button event or call onblur event but for this you need web service password field never allow Textchange event
for username and password remembering you can use session or cookies
Sohail Shaikh
Srikanth Kas...
Contributor
4289 Points
883 Posts
Re: OnTextChanged and the events by clicking on Submit-button doesn't work fine
Aug 31, 2012 12:12 PM|LINK
Try Cookies :
For Storing :
HttpCookie myCookie = new HttpCookie("myCookie");
Response.Cookies.Remove("myCookie");
Response.Cookies.Add(myCookie);
myCookie.Values.Add("txtUserName", txtUserName.Text);
myCookie.Values.Add("txtPassword", txtPassword.Text);
Retreival :
if (HttpContext.Current.Request.Cookies["myCookie"] != null)
{
txtUserName.Text = HttpContext.Current.Request.Cookies["myCookie"]["txtUserName"].ToString();
txtPassword.Text = HttpContext.Current.Request.Cookies["myCookie"]["txtPassword"].ToString();
}
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
WesleyN
Member
1 Points
8 Posts
Re: OnTextChanged and the events by clicking on Submit-button doesn't work fine
Aug 31, 2012 01:27 PM|LINK
And in which event do I declare values?
The password and username are in the UserControl. And the Login-button is in the Default.aspx.
How can I move the values to the default page?
Sage Gu - MS...
Contributor
6693 Points
578 Posts
Microsoft
Re: OnTextChanged and the events by clicking on Submit-button doesn't work fine
Sep 04, 2012 09:52 AM|LINK
Hi WesleyN,
I'm not sure why you would like to seperate the login button rather than merge them as a web user control. However, you can try to test my code below and change it depends on your requirement. I create all files in a folder named CustomerControl.
uclLogin.ascx
MasterPage.master
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="CustomerControl_MasterPage" %> <%@ Register src="uclLogin.ascx" tagname="uclLogin" tagprefix="uc1" %> <!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></title> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="form1" runat="server"> <div> <uc1:uclLogin ID="uclLogin1" runat="server" /> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </form> </body> </html>Default.aspx file
<%@ Page Title="" Language="C#" MasterPageFile="~/CustomerControl/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="CustomerControl_Default" %> <%@ Register src="uclLogin.ascx" tagname="uclLogin" tagprefix="uc1" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:Button ID="Button1" runat="server" Text="Get" onclick="Button1_Click" /> <br /> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text=""></asp:Label> </asp:Content>Default.aspx.cs
public partial class CustomerControl_Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { CustomerControl_uclLogin ccuc = (CustomerControl_uclLogin)Master.FindControl("uclLogin1"); if(ccuc != null) { TextBox username = (TextBox)ccuc.FindControl("TextBox1"); TextBox password = (TextBox)ccuc.FindControl("TextBox2"); if (username != null) { Label1.Text = username.Text; } if (password != null) { Label2.Text = password.Text; } } } }Regards,
Sage
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
WesleyN
Member
1 Points
8 Posts
Re: OnTextChanged and the events by clicking on Submit-button doesn't work fine
Sep 04, 2012 11:14 AM|LINK
Sage Gu,
Thank you very much!
This is a solution what I'm searching for.
I've used a private control FAddress. And this control has everytime a different coat of the current UserControl.
private UserControl FAddress; protected void btnLogin_Click(object sender, EventArgs e) { try { uclLogin ccuc = (uclLogin)FAddress; if (ccuc != null) { ... }