Tuesday, 22 November 2016

.asp webform user control event


add control folder, add cousescontrol.ascx

add drop down list to cousescontrol.ascx
change auto post back to true in property window

//course control.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ctti.Data;

namespace CttiDemo.Controls
{
    public partial class CoursesControl : System.Web.UI.UserControl
    {
        //Step 3: define the public event
        public event CourseSelectionDelegate CourseSelect;

        private CTTIEntities1 DB = new CTTIEntities1();

        //Property returns the selected value of the DDL as an int instead of string
        public int SelectedId
        {
            get
            {
                return int.Parse(uxCourses.SelectedValue);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //populate the DDL
            if (!IsPostBack)
            {
                uxCourses.DataSource = DB.Courses.Select(c => new { Id = c.Id,
                                                         Name = c.CourseName }).ToList();
                uxCourses.DataTextField = "Name";
                uxCourses.DataValueField = "Id";
                uxCourses.DataBind();

                //raise the event first time page loads so event handler can load form
                uxCourses_SelectionChanged(this, null);
            }
        }

        protected void uxCourses_SelectionChanged(object sender, EventArgs args)
        {
            //Step 4: raise the event
            //if event is not raised, raise event
            if(CourseSelect != null)
            {
                //we need to get the course from the data layer using the id value from DDL
                int id = int.Parse(uxCourses.SelectedValue);

                Course crs = DB.Courses.Find(id);

                var c = new CourseEventArgs
                {
                    Id = crs.Id,
                    CourseCode = crs.CourseCode,
                    CourseName = crs.CourseName,
                    Description = crs.Description,
                    Duration = crs.Duration,
                    Fee = crs.Fee
                };

                //fire event everywhere 
                CourseSelect.Invoke(this, c);
            }
        }
    }

    //Step 1: define a custom event args class
    public class CourseEventArgs : EventArgs
    {
        public int Id { get; set; }
        public string CourseCode { get; set; }
        public string CourseName { get; set; }
        public decimal Fee { get; set; }
        public int Duration { get; set; }  
        public string Description { get; set; } 
    }

    //Step 2: define a delegate
    public delegate void CourseSelectionDelegate(object sender, CourseEventArgs args);

}

------------------------------------------------------------------

drag coursecontrol onto courses.aspx webform

//course.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CttiDemo
{
    public partial class Courses : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           //drop down list from coursecontrol.ascx fires event, courses.asp receives event
            uxCourses.CourseSelect += UxCourses_CourseSelect;            
        }

        //event handler
        private void UxCourses_CourseSelect(object sender, Controls.CourseEventArgs args)
        {
            uxName.Text = args.CourseName;
            uxCode.Text = args.CourseCode;
            uxFee.Text = args.Fee.ToString("c");
            uxDuration.Text = args.Duration.ToString() + " hrs";
            uxDescription.Text = args.Description;
        }
    }
}



Monday, 21 November 2016

加拿大公司发明神器 8分钟可永久恢复视力

就在全世界的科技圣地 ~ 美国硅谷
一个信仰 改变世界 的地方
出了一位要为近视患者扭转乾坤的大神
加思·韦伯(Garth Webb)
曾是一名普通的验光师
现任加拿大 Ocumetics 科技公司的CEO
用了8年时间,
发明出来了一件神器
仿生晶体 
就凭这小小的东西
Webb向公众媒体放出话来:
“将来,世界上不会再有近视”
“我将永远消灭眼镜,还有隐形眼睛”
千万不要以为这个又是一种新的隐形眼镜,不是的
它由惰性亲生物材料制成,不会遭到人体排斥
也不会变质损耗,可终身矫正视力
只要把这个小片片放到你的眼睛里
再用生理盐水冲洗
10秒后,这个仿生晶体就会扩散到你的整个眼球
只要把这个小片片放到你的眼睛里
再用生理盐水冲洗
10秒后,这个仿生晶体就会扩散到你的整个眼球
8分钟后
困扰你一生的近视就离你远去了
整个过程,无需开刀,无需麻醉
做完休息一下就可以回家了
从此之后,当你和老公去游泳的时候
你看到的他,将从这样
变成这样
不仅如此
在植入这个仿生晶体后
你还可以拥有比普通人好3倍的视力!
也就是说,假如普通人能看清3米之外时钟上的指针
你就能看清楚9米之外的
如果是同样的距离,你能比普通人看到更清晰的细节
约上老公/老婆去植入一个
“神眼侠侣”不是梦啊!
更加牛逼闪闪的是
发明者Webb博士还表示,
在未来,
眼睛里的仿生晶体可以直接通过蓝牙与手机相连,
你看到的一切都可以被手机录下来!
逆天了有木有!
拥有这项技术的Ocumetics公司宣布这项技术已经完成了动物实验,目前已经进入了临床测试阶段。 
目前研究表明,这项技术非常安全,不会对眼睛产生副作用,同时也不会有闪光或是夜盲的问题。 
不过,仅限年龄超过25岁以上的成年人使用,因为超过这年纪的人眼睛结构才是完全定型,可以达到一劳永逸的效果。只要超过了25,上不封顶,就算你80岁了,只要眼球结构经过检查还可以负担这个小手术,就都可以接受矫正! 
据悉该技术最快将于2017年上市,
并且价格也不过分,
一只眼睛3200加币,
约合人民币1万6千左右。

Mortgage Centre Canada (Focal Mortgage)

         各银行和机构特许代理
  
全国各省正规持牌,口碑最佳公司,您的第一选择! Please Call 1-888-973-6588 to Get Your Best Offer!.
 
Mortgage Centre Canada (Focal Mortgage)
  • Calgary: (403) 536-9991             (Alberta Licensed)
  • Edmonton: (780) 701-1868        
  • Saskatchewan: (306) 500-7568    (SK license No. 316375)
  • BC: (604) 635-1889                    (BC License No. x030273)
  • ON: (905) 889-9990                   (Ontario License No. 10427)
  • Toll Free: 1(888) 973-6588
 
 
 
Variable Term:
  • 5Yr low to 2.05% (P-0.65%)! 2.0%(Highratio)!
 
Fix Term: November 21, 2016
 
 
Fix TermRate
1 Yr  2.09%  
2 Yrs 2.04% 
3 Yrs  2.09%  
4Yrs2.29%
5 Yrs  2.39%
 
3 Steps to Get Your Mortgage Funding:
  • Step 1:  Download the Form1, Form 2 and fill out all the requisite fields; you can then fax signed copy to 1-888-600-1538 or email to wyhsea@hotmail.com or  support2@mortgagecentres.net
  • Step 2: You will receive, via email, an approved commitment from us within 2 business days.
  • Step 3: The bank branch most convenient for you, either by location or choice, will contact you to set up an appointment in order to finalize your mortgage. At the same time, your lawyer will receive Mortgage Instructions.
 
 
加拿大房贷中心 - 网上申请,诚信可靠,口碑最佳 !
三日批准,三部到位,服务全国:
第一步:    下载申请表Download the Form1, Form 2
             电邮: wyhsea@hotmail.com or support2@mortgagecentres.net
      传真: 1-888-600-1538
第二步:     本中心致电您确认具体信息和利息, 2 日内交付批准合约.
第三步:     您到本中心指定的,距离您最近的银行分行或您的律师行完成最后签字.
  • 购房,转贷,续约!
  • 重组贷款 减免罚款!
  • 各类工商物业如建筑贷款,养老院,教堂,油站 等低息4%起!!!
 
Focal Mortgage Inc.-the Mortgage Centre, has been with MCC as an independently owned and operated for 12 years and  is also an authorized mortgage brokerage by TD, Scotia Bank ...over 82 Banks and Institutions.
  •         Calgary Branch: 1450 633 6th Ave SW, Calgary, AB T2P 2Y5
  • BC Branch: 6 8726 159th St, Surrey, BC, V4N 0A8
  • SK: 1030B-F 8th street East, Saskatoon, Saskatchewan, S7H 0R9.
  •               Toronto Head Office:  350 Highway 7 East, #PH05, Richmond Hill ON L4B 3N2
 
List Rates herewith are not suitable for everyone, lenders request your qualified credit, income, mortgage amount, residential properties only and may be changed without notice. Suggest you call us to confirm!
 注意:本中心公布的贷款利息不适合所有客户. 金融机构需要对您的申请贷款条件例如信用,收入水平,房屋用途等等 进行考核,利息如发生紧急变化,本网站可能不能及时更新,依据电话及时查询为准.
 
We'll get Canada's leading lenders
to compete for your mortgage
so you get the best available deal.

  
 
 
How to get the best mortgage

 

在这些公司,软件工程师可以轻松赚到$11万+

地球人都知道,搞技术,赚得多。不管学习的过程有多么的痛苦,有多么的令人抓狂,有多么的灭绝人性,但是结局还是幸福的:高薪+一堆等着被泡的妹子(这点需要运气)。找工作网站Glassdoor根据给予软件工程师的平均年薪情况给出一份名单,在这份名单上的公司都格外慷慨,软件工程师可以轻松转到$11万+的年薪哟!还不赶紧来看一看?

  18. eBay: $113,549

  

  在eBay,一个软件工程师的平均基本年薪是$107,021,基本年薪从初级职位的$87,000到高级职位的$168,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$113,549。

  17. 甲骨文(Oracle): $116,514

  

  在甲骨文,一个软件工程师的平均基本年薪是$113,870,基本年薪从初级职位的$62,000到高级职位的$158,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$116,514。

  16. 微软(Microsoft): $116,967

  

  在微软,一个软件工程师的平均基本年薪是$104,659,基本年薪从初级职位的$73,000到高级职位的$152,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$116,967。

  15. 科磊半导体(KLA-Tencor): $117,167

  

  在科磊半导体,一个软件工程师的平均基本年薪是$110,073,基本年薪从初级职位的$74,000到高级职位的$138,000不等。算上奖金和其他补贴,软件工程师的平均年为$117,167。

  14. 英特尔(Intel): $117,643

  

  在英特尔,一个软件工程师的平均基本年薪是$105,201,基本年薪从初级职位的$65,000到高级职位的$176,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$117,643。

  13. Nvidia: $117,804

  

  在Nvidia,一个软件工程师的平均基本年薪是$115,116,基本年薪从初级职位的$76,000到高级职位的$190,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$117,804。

  12. 亚马逊(Amazon): $118,121

  

  在亚马逊,一个软件工程师的平均基本年薪是$102,450,基本年薪从初级职位的$50,000到高级职位的$180,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$118,121。

  11. 赛门铁克(Symantec): $120,553

  

  在赛门铁克,一个软件工程师的平均基本年薪是$117,357,基本年薪从初级职位的$70,000到高级职位的$149,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$120,553。

  10. IAC: $120,755

  

  在IAC,一个软件工程师的平均基本年薪是$119,067,基本年薪从初级职位的$87,000到高级职位的$168,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$120,755。

  9. 雅虎(Yahoo): $125,366

  

  在雅虎,一个软件工程师的平均基本年薪是$117,968,基本年薪从初级职位的$74,000到高级职位的$209,000不等。算上奖金和其他补贴,软件工程师的平均年薪为 $125,366。

  8. 思科(Cisco): $130,221

  

  在思科,一个软件工程师的平均基本年薪是$117,324,基本年薪从初级职位的$65,000到高级职位的$165,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$130,221。

  7. 博科(Brocade): $132,036

  

  在博科,一个软件工程师的平均基本年薪是$122,746,基本年薪从初级职位的$82,000到高级职位的$183,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$132,036。

  6. 苹果(Apple): $138,300

  

  在苹果,一个软件工程师的平均基本年薪是$122,039,基本年薪从初级职位的$68,000到高级职位的$200,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$138,300。

  5. PayPal: $146,795

  

  在PayPal,一个软件工程师的平均基本年薪是$130,583,基本年薪从初级职位的$99,000到高级职位的$153,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$146,795。

  4. Arista: $151,648

  

  在Arista,一个软件工程师的平均基本年薪是$121,236,基本年薪从初级职位的$82,000到高级职位的$163,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$151,648。

  3. 谷歌(Google): $164,683

  

  在谷歌,一个软件工程师的平均基本年薪是$126,852,基本年薪从初级职位的$82,000到高级职位的$226,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$164,683。

  2. 领英(LinkedIn): $170,839

  

  在领英,一个软件工程师的平均基本年薪是$131,956,基本年薪从初级职位的$88,000到高级职位的$188,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$170,839。

  1. 脸书(Facebook): $177,014

  

  在脸书,一个软件工程师的平均基本年薪是$125,829,基本年薪从初级职位的$83,000到高级职位的$201,000不等。算上奖金和其他补贴,软件工程师的平均年薪为$177,014。

HBICtv: Ultra Rich Asian Girls

https://www.youtube.com/watch?v=VR9Xu878pkE

Saturday, 19 November 2016

asp.net webform pass parameter by session




//enroll.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CttiDemo
{
    public partial class Enrollment : System.Web.UI.Page
    {
        List<int> courses = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            //get the id collection from session and if it doesn't exist we add it
            if (Session["courses"] != null)
                courses = (List<int>)Session["courses"];
            else
                courses = new List<int>();
        }

        protected void uxEnrol_Click(object sender, EventArgs e)
        {
            //get the course id from the drop down and add the value to the list
            var id = int.Parse(uxCourses.SelectedValue);
            courses.Add(id);

            //add the list to the session
            Session["courses"] = courses;
            //or
            //Session.Add("courses", courses);
        }
    }
}

-----------------------------------------------------------
//payment.cs

using Ctti.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace CttiDemo
{
    public partial class Payment : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //get the courses id collection from session if it exists
                if(Session["courses"] != null)
                {
                    var courses = (List<int>)Session["courses"];
                    var db = new CTTIEntities1();
                    var list = db.Courses.Where(c => courses.Contains(c.Id)).ToList();
                    uxCourses.DataSource = list;
                    uxCourses.DataBind();
                    //uxCourses.Columns[0].Visible = false;
                }
            }
        }


        protected void uxCourses_PreRender(object sender, EventArgs e)
        {
            if (uxCourses.Columns.Count > 0)
                uxCourses.Columns[0].Visible = false;
        }

        //This is the event to capture when each row is being added and...
        protected void uxCourses_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //...make the first cell of the row being added invisible!!!
            e.Row.Cells[0].Visible = false;
        }
    }
}

.asp web form pass parameter by url, cookie



//default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="webform_pass_parameter._default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <table>
            <tr>
                <td style ="width:100px"><asp:Label ID="Label1" runat="server" Text="User ID:"></asp:Label></td>
                <td style ="width:200px"><asp:TextBox ID="ux_id" runat="server"></asp:TextBox></td>
            </tr>

//table rows follows first row style
            <tr>
                <td> Password:</td>
                <td><asp:TextBox ID="ux_password" runat="server"></asp:TextBox></td>
            </tr>

            <tr>
                <td colspan="2" style="text-align:center">
                    <asp:Button ID="Button2" runat="server" Text="submit" Width="87px" OnClick="Button2_Click" />
                    &nbsp;
                    <asp:Button ID="Button3" runat="server" Text="cookie" Width="83px" OnClick="Button3_Click" />
                </td>
            </tr>
        </table>      
   
    </div>
    </form>
</body>
</html>

------------------------------------------------------------------
//default.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace webform_pass_parameter
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            string url = string.Format("~/process.aspx?userid={0}&password={1}",ux_id.Text, ux_password.Text);

            Response.Redirect(url);
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            var cookie = new HttpCookie("userid", ux_id.Text);
            cookie.Expires = DateTime.Now.AddMinutes(1);
            Response.Cookies.Add(cookie);

            cookie = new HttpCookie("password", ux_password.Text);
            cookie.Expires = DateTime.Now.AddMinutes(1);
            Response.Cookies.Add(cookie);

            Response.Redirect("~/process.aspx");
        }
    }
}

----------------------------------------------------------------------
//process.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace webform_pass_parameter
{
    public partial class process : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //string user_id = Request.QueryString["userid"];
            //string _password = Request.QueryString["password"];

            //if (user_id != "" && _password != "")
            //{
            //    string message = string.Format("<h3>wecome {0}, your password is {1}</h3>", user_id, _password);

            //    Response.Write(message);
            //}

            if (Request.Cookies["userid"] != null && Request.Cookies["password"]!=null)
            {
                string user_id = Request.Cookies["userid"].Value;
                string password = Request.Cookies["password"].Value;
                string message = string.Format("<h3>welcome {0}, your password is {1} </h3>",user_id,password);

                Response.Write(message);
            }
        }
    }
}