我在Angular2应用程序中有一个输入字段的指令。我想停止粘贴或 Ctrl + V 到该指令的主机,所以我使用了以下代码,代码运行正常。
@HostListener('paste', ['$event']) blockPaste(e: KeyboardEvent) {
e.preventDefault();
}
我还想停止Drop事件到该主机。我该怎么办?
答案 0 :(得分:2)
我猜到了。它正在发挥作用。
@HostListener('drop', ['$event']) blockDrop(e: MouseEvent) {
e.preventDefault();
}
答案 1 :(得分:2)
protected void Page_Load(object sender, EventArgs e)
{
String UserName = Utils.Session.Get(Constants.SessionObjects.UserName);
if (!IsPostBack)
{
DataTable dt = this.GetData();
Listview1.DataSource = dt;
Listview1.DataBind();
}
}
private DataTable GetData()
{
string RetailLink = ConfigurationManager.ConnectionStrings["DefaultDB"].ConnectionString;
using (SqlConnection con = new SqlConnection(RetailLink))
{
using (SqlCommand cmd = new SqlCommand("EXEC sp_mProduct_Sel_ByPrincipalRetailer#PWA " + UserName + ", " + PricipalID.ToInt32()))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
}
}
protected void btnProceedOrder_Click(object sender, EventArgs e)
{
foreach (ListViewDataItem row in Listview1.Items)
{
TextBox txtQuantity = row.FindControl("txtQuantity") as TextBox;
string Quantity = txtQuantity.Text.ToString(); //string Quantity keep getting "0", I need to get the value that user insert.
}
}
我希望它可能会有所帮助。