1)自定义2个Button 注册的"onclick"方式不一样,如下代码:
protected override void Render(HtmlTextWriter writer)
{
//自定义按钮调用后台事件
Table table = FpSpreadGV.FindControl("cmdTable") as Table;
TableCell cell1 = new TableCell();
Button btn2 = new Button();
btn2.ID = "btnSave";
btn2.Text = "保存";
btn2.Width = 65;
btn2.Attributes.Add("class", "btn_2k3");
btn2.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(FpSpreadGV, "btnSave,-1,-1") + "; return false;");
cell1.Controls.Add(btn2);
table.Rows[0].Cells.Add(cell1);
Button btn1 = new Button();
btn1.ID = "btnSubmit";
btn1.Text = "提 交";
btn1.Width = 65;
btn1.Attributes.Add("class", "btn_2k3");
btn1.Attributes.Add("onclick", "return SubmitWin()");
cell1.Controls.Add(btn1);
table.Rows[0].Cells.Add(cell1);
}
2 在WEB页面上放一个lbl的Lable控件,然后当点击保存按钮的时候lbl会显示“保存成功”,
当点击提交按钮的时候,lbl不会显示,要怎么样才可以让lbl显示内容?
--希望用这种方式注册,因为点击的时候可以弹出确认框 btn1.Attributes.Add("onclick", "return SubmitWin()");
但是执行后lbl控件不显示。
protected void FpSpreadGV_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
{
switch (e.CommandName)
{
case "btnSubmit":
lbl.text="提交成功";
break;
case "btnSave":
lbl.text="保存成功";
break;
}
} |
|