設定值後面未做服務器控件設定值後面未做服務器控件在代碼的HTML控件
<input type="text" name="txt" />
<!--Please note I don't want put 'runat="server"' here to get the control in code behind-->
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
後面的代碼:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//If I want to initlize some value in input, how can I set here
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Request["txt"] // Here I am getting the value of input
}
runat =「server」似乎也將名稱更改爲例如「ctl00 $ Main $ Something」實際上打破了應該到別處的表單(例如PayPal)的整個帖子。 – Johncl 2012-09-17 13:55:49