Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Cunha1

Cursor no campo

Recommended Posts

Boa tarde,

 

Gostaria de quando entrar na pagina de login o cursor já estivesse no primeiro campo piscando ao invez de ter que clicar no campo.

 

Como faço para deixar o cursor disponivel no primeiro campo?

 

 

Obrigado.

 

Igor Cunha.

Compartilhar este post


Link para o post
Compartilhar em outros sites

No Load da Página coloca um NomeDoControle.Focus().

 

Acho que isso resolve.

 

Abraços

Compartilhar este post


Link para o post
Compartilhar em outros sites

O codigo é o seguinte:

 

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Web.Security;
using System.Reflection;

namespace Qualificacao_Atendimento
{
	/// <summary>
	/// Summary description for Login.
	/// </summary>
	public class Login : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label ErroLogin;
		protected System.Web.UI.WebControls.TextBox txt_Login;
		protected System.Web.UI.WebControls.TextBox txt_Senha;
		protected System.Web.UI.WebControls.Label lblVersao;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
		protected System.Web.UI.HtmlControls.HtmlImage IMG1;
		protected System.Web.UI.WebControls.ImageButton bt_ok;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (Session["Versao"] == null) 
			{
				string strVersao = "";
				Assembly assy = Assembly.GetExecutingAssembly();
				AssemblyVersionAttribute[] versionAttrs = (AssemblyVersionAttribute[])assy.GetCustomAttributes(typeof(AssemblyVersionAttribute), false);
				if (versionAttrs != null && 0 < versionAttrs.Length) 
				{
					strVersao = versionAttrs[0].Version;
				}
				else
					strVersao = Assembly.GetExecutingAssembly().GetName().Version.ToString();

				Session["Versao"] = strVersao;

				lblVersao.Text = "Versão: " + strVersao;
			}

			if (Request["codatendente"] != null)
			{
				string cod_serv = "";
				Vox.Net.Database.cDataBase db = new Vox.Net.Database.cDataBase();
				string sql;
				DataTable dt;	

				System.Web.HttpCookie userCookie = new System.Web.HttpCookie("QA");
				userCookie["Cod_Usu"] = Request["codatendente"].ToString();
				userCookie["CodFunc"] = "1";
				DateTime dataExpiracao = new DateTime(DateTime.Now.AddDays(1).Year, DateTime.Now.AddDays(1).Month, DateTime.Now.AddDays(1).Day, 0, 1, 0, 0);
				userCookie.Expires = dataExpiracao;
				Response.Cookies.Add(userCookie);
				string cod_evpa;
				if (Request["cod_evpa"] == null)
				{
					sql = "Select seq_evpa.nextval seq from dual";
					//sql="Select "+InstanciaQA+"seq_qualificacao.nextval seq from dual";
					dt = db.criarDataTable(sql);
					cod_evpa = dt.Rows[0][0].ToString();
					dt.Dispose();
				}
				else
				{
					cod_evpa = Request["cod_evpa"].ToString();
				}

				cod_serv = Request["cod_serv"];
				string ddd = Request["ddd"];
				string telefone = Request["chamador"];
				FormsAuthentication.SetAuthCookie(Request["codatendente"].ToString(), false);
				//Response.Redirect("teste.asp?cod_serv="+cod_serv+"&cod_evpa="+cod_evpa+"&telefone=7121027616");
				if ((Request["tipourl"] == null) || Request["tipourl"].ToString().Equals(""))
					Response.Redirect("agentscreen.aspx?codatendente="+Request["codatendente"]+"&cod_serv="+cod_serv+"&cod_evpa="+cod_evpa+"&telefone="+telefone+"&tipoqa="+Request["tipoqa"]+"&ddd="+ddd+"&unipro_protocolo="+Request["unipro_protocolo"]+"");
				else
					Response.Redirect(FormsAuthentication.GetRedirectUrl(Request["codatendente"].ToString(),false));
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{	
			this.txt_Login.TextChanged += new System.EventHandler(this.txt_Login_TextChanged);
			this.bt_ok.Click += new System.Web.UI.ImageClickEventHandler(this.bt_ok_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void bt_ok_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			string autenticaLdap = ConfigurationSettings.AppSettings.Get("QA.Ldap.Autentica");
			string procAutentica = (autenticaLdap.Equals("S") ? "AUTENTICA_USUARIO2" : "AUTENTICA_USUARIO");
			int indice = (autenticaLdap.Equals("S") ? 2 : 3);

			Vox.Net.Database.cDataBase db = new Vox.Net.Database.cDataBase();		
			string Tipo_Banco = ConfigurationSettings.AppSettings.Get("Vox.Net.Database.Type");
			DataTable dt =  db.CriarCabecalhoProcedureIO();
			
			dt.Rows.Add(db.CriarParametrosProcedureIO(Vox.Util.cUtil.Coloca_Arroba(Tipo_Banco)+
				"P_Login","VarChar",20,"input",txt_Login.Text,0,DateTime.Now));
			if (autenticaLdap.Equals("N"))
				dt.Rows.Add(db.CriarParametrosProcedureIO(Vox.Util.cUtil.Coloca_Arroba(Tipo_Banco)+
					"P_Senha","VarChar",20,"input",txt_Senha.Text,0,DateTime.Now));
			dt.Rows.Add(db.CriarParametrosProcedureIO(Vox.Util.cUtil.Coloca_Arroba(Tipo_Banco)+
				"P_Entidade","VarChar",50,"input","QAT",0,DateTime.Now));
			dt.Rows.Add(db.CriarParametrosProcedureIO(Vox.Util.cUtil.Coloca_Arroba(Tipo_Banco)+
				"P_StRet","VarChar",50,"output",null,0,DateTime.Now));

			try
			{
				db.ExecutarProcedureIO(procAutentica, dt);			
				//				0- Autenticacao OK
				//				1- Matricula inexistente
				//				2- Senha Não confere
				//				3- Acesso negado a função
				//			  4- Usuario Bloqueado
				ErroLogin.ForeColor = Color.Red;
				if (dt.Rows.Count > 0)
				{
					string ret = dt.Rows[indice][4].ToString().Split('@')[0];
					ErroLogin.Text = "PCMA: " + (ret.Equals("1") ? "Matricula inexistente" : (ret.Equals("2") ? "Senha Não confere" : (ret.Equals("3") ? "Acesso negado a função" : (ret.Equals("4") ? "Usuário Bloqueado" : (ret.Equals("0") ? "Autenticacao OK" : "Falha na autenticação!")))));

					if (ret.Equals("0")) 
					{
						System.Web.HttpCookie userCookie = new System.Web.HttpCookie("QA");
						userCookie["Cod_Usu"] = dt.Rows[indice][4].ToString().Split('@')[1];						
						userCookie["CodFunc"] = dt.Rows[indice][4].ToString().Split('@')[2];
						Response.Cookies.Add(userCookie);						

						//Autenticação LDAP
						//string retLdap = (autenticaLdap.Equals("S") ? getAutenticacaoLdap(txt_Login.Text, txt_Senha.Text) : "1|Autenticação Presumida LDAP.");

						string retLdap = "";
						if(autenticaLdap.Equals("S"))
						{
							retLdap = getAutenticacaoLdap(txt_Login.Text, txt_Senha.Text);
						} 
						else
						{
							retLdap = "1|Autenticação Presumida LDAP.";
						}

						if (retLdap.Split('|')[0].Equals("1"))
						{
							ErroLogin.Text="";
							dt.Dispose();
							FormsAuthentication.RedirectFromLoginPage(dt.Rows[indice][4].ToString().Split('@')[1], false);
						}
						else
							//ErroLogin.Text = "LDAP: " + retLdap.Substring(2);
							ErroLogin.Text = "LDAP: " + retLdap.Split('|')[1];
					}
				}
				else
				{
					ErroLogin.Text = "Erro no processo de Login!";
				}
				dt.Dispose();
			}
			catch (Exception ex)
			{
				ErroLogin.Text = ex.Message;
				Response.Redirect("Login.aspx");
			}
		}
		
		public static string getAutenticacaoLdap(string usuario, string senha) 
		{
			WSConexao.Servicos wsconexaoldap = new WSConexao.Servicos();

			string autenticacao = wsconexaoldap.ValidacaoNDS(usuario, senha, "", "", "", "", "", "", "");

			string[] ret = autenticacao.Split('#');

			string retornoOk = ret[0];
			string erro = ret[1];

//			Vox.Net.Ldap conexaoLdap = new Vox.Net.Ldap();
//			string ldapIPs = ConfigurationSettings.AppSettings.Get("QA.Ldap.IPs");
//			ArrayList arrIPLIST = new ArrayList(ldapIPs.Split('|'));
//
//			string ldapArvore = ConfigurationSettings.AppSettings.Get("QA.Ldap.Arvore");
//			string ldapOk = ConfigurationSettings.AppSettings.Get("QA.Ldap.Ok");
//
//			string retorno = "";
//			try
//			{
//				retorno = conexaoLdap.LDAPMultiConsulta(usuario, senha, arrIPLIST, "", ldapArvore);
//			}
//			catch
//			{
//				return "0|LDAP não responde.";
//			}
//
//			string[] trataRetorno = retorno.Split('#');
//			int qtdRet = Convert.ToInt32(trataRetorno[0].Substring(trataRetorno[0].Length-1));
//			
//			string retornoOk = "0";
//			string erro = "";
//
//			for (int i = 1; i < trataRetorno.Length-1; i++)
//			{
//				string[] ret = trataRetorno[i].Split('|');
//				retornoOk = (ret[0].Equals(ldapOk) ? "1" : retornoOk);
//				erro = (!ret[0].Equals(ldapOk) ? ret[5] : "");
//			}

			return retornoOk + "|" + erro;
		}

		private void txt_Login_TextChanged(object sender, System.EventArgs e)
		{		
		}
	}
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom dia,

 

Desculpe minha ignorancia mais como eu faó para olhar qual é o tipo do container? Esse codigo que estou trabalhando não foi eu quem fez.

 

Obrigado.

 

Igor Cunha.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.