2010-09-29 25 views
0

我有一個web項目,其中包含兩個按鈕在view.when我點擊一個按鈕一些文本框以及第二個按鈕必須是可見的。在輸入數據在文本框中,當我試圖點擊第二個按鈕,它不工作。我該怎麼做才能使它工作? 在此先感謝。在單個視圖中的多個按鈕

回答

11

拉胡爾試試這個

在aspx頁面

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
     <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> 
     <asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" /> 

在aspx.cs頁面

protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!IsPostBack) 
     { 
      Button2.Visible = false; 
      TextBox1.Visible = false; 
     } 
    } 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
     Button2.Visible = true; 
     TextBox1.Visible = true; 
    } 
    protected void Button2_Click(object sender, EventArgs e) 
    { 
     TextBox1.Text = "Testing"; 
    }