protected void Page_Load(object sender, EventArgs e)
    {
        //ClientCredentials cc = new ClientCredentials();
        //Engine obj = new Engine();

        EngineClient objEngineClient = new EngineClient();
        MobileMeetingProject.EsEngine.MyLoginResult lr = objEngineClient.Login("*****@*****.**", "Jhansibk5");

        GridView1.DataSource = objEngineClient.GetYears();
        GridView1.DataBind();

        //userid
        GridView2.DataSource = objEngineClient.GetEvents("bc705759-0855-e411-a06d-6c3be5a82838","2014");
        GridView2.DataBind();

        //eventid
        GridView3.DataSource = objEngineClient.GetAttendees("2ea2e9ea-06a6-4362-97c8-8635c0cbb9ae");
        GridView3.DataBind();

        //for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        //{
        //    if (GridView2.Rows.Count == 0)
        //    {
        //        GridView2.DataSource = objEngineClient.GetEvents("bc705759-0855-e411-a06d-6c3be5a82838", GridView1.Rows[i].Cells[0].Text);
        //        GridView2.DataBind();
        //    }
        //    else
        //    {
        //        break;
        //    }
        //}

        //GridView2.DataSource = objEngineClient.GetEvents(lr.UserId.ToString() , "2013");
        //GridView2.DataBind();
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (this.IsValid)
        {
            SFUsername = string.Empty;
            SFPassword = string.Empty;
            Domain = string.Empty;
            try
            {
                EngineClient EngClient = Authentication.GetEngineClient();
                SFUsername = username.Text.Trim();
                SFPassword = pass.Text.Trim();
                //Domain = SFUsername.Split(new char[] { '@' })[1].ToString();
                //SFUsername = SFUsername.Split(new char[] { '@' })[0].ToString();
                //Domain = Domain.Split(new char[] { '.' })[0].ToString();
                EngClient = new EngineClient();
                MobileMeetingProject.EsEngine.MyLoginResult CurrentUser = EngClient.Login(username.Text.Trim(), pass.Text.Trim());
                // CurrentUser = EngClient.Login(SFUsername, SFPassword);

                if (CurrentUser.OpResult.Success)
                {
                    HttpCookie ContactCookie = new HttpCookie("ContactInfo");
                    ContactCookie["ContactTitle"] = CurrentUser.UserId.ToString();
                    ContactCookie["ContactName"] = CurrentUser.UserName.ToString();
                    ContactCookie.Expires = DateTime.Now.AddMonths(1);

                    Response.Cookies.Add(ContactCookie);

                    //FormsAuthentication.RedirectFromLoginPage(CurrentUser.UserId.ToString(), false);
                    //FormsAuthentication.RedirectFromLoginPage("bc705759-0855-e411-a06d-6c3be5a82838", false);
                    Response.Redirect("Selection.aspx");
                    /* if (chkbox_remeberme.Checked)
                     {
                         HttpCookie SchedulerLoginCookie = new HttpCookie("SchedulerLoginCookie");
                         SchedulerLoginCookie["Username"] = txt_username.Text.Trim();
                         SchedulerLoginCookie["Password"] = Params.Encrypt(txt_password.Text.Trim());
                         SchedulerLoginCookie.Expires = DateTime.Now.AddDays(7);

                         Response.Cookies.Add(SchedulerLoginCookie);
                     }
                     else
                     {
                         HttpCookie SchedulerLoginCookie = Request.Cookies.Get("SchedulerLoginCookie");
                         if (SchedulerLoginCookie != null)
                         {
                             SchedulerLoginCookie.Expires = DateTime.Now.AddYears(-1);
                             Response.Cookies.Add(SchedulerLoginCookie);
                         }
                     }

                     /*if (Request.QueryString["returnurl"] != null && Request.QueryString["returnurl"].Trim() != string.Empty)
                     {
                         Response.Redirect(Request.QueryString["returnurl"]);
                     }
                     else
                     {
                         Response.Redirect("~/Pages/Welcome.aspx");
                     }*/
                }
                else
                {
                    //lbl_msg.Text = "Authentication failed: invalid username or password";

                }
            }
            catch (Exception ex)
            {
                //lbl_msg.Text = "Authentication failed: " + ex.Message;
            }
        }
    }