runat=server表明该控件是再服务器端执行的。而HTML控件如果不转换为服务器控件的话,在code-behind里面是取不倒值的。
还有你的代码有问题,应该是
if(!IsPostBack)
{
....
}

解决方案 »

  1.   

    <Form runat="server">
    <asp:label runat="server" id="lblMsg"/>
    Message:<Input type="Submit" value="OK" id="PressOK"
    runat="server"> 
    </Form>
      

  2.   

    <Input type="Submit" value="OK" id="PressOK"
    runat="server">
    (1)PressOk button 是一个Submit型的服务器端控件点击它将表单(form)提交给本页
    (2)void Page_Load ( Object Source,EventArgs E) {if (Page.IsPostBack) {
            lblMsg.Text = "Hello world!";
        }
    } 
    函数是form被load时运行的函数,第一次加载本页时Page.IsPostBack 为false所以不执行lblMsg.Text = "Hello world!";当你点击botton表单被提交又一次被加载此时Page.IsPostBack为true所以执行lblMsg.Text = "Hello world!";