提交按鈕我創建不會觸發,即使我在Visual Studio中設置斷點試圖調試它。提交不自定義WebControl(服務器控制)
public class CustomControl : WebControl
{
protected override void Render(HtmlTextWriter writer)
{
// Submit
var submitButton = new Button{Text = "Submit", ID = "SubmitButton"};
submitButton.Click += new EventHandler(SubmitClick);
Controls.Add(submitButton);
base.Render(writer);
}
protected void SubmitClick(object sender, EventArgs e)
{
Controls.Add(new LiteralControl("submited"));
OnSubmit(EventArgs.Empty);
}
}
它加入這樣的頁面
<form id="form1" runat="server">
<MyControls:CustomControl runat="server" />
</form>
或者,也許我只是有此錯誤的做法。
控制甚至不會使我一夏精,還是? –