2011-06-21 28 views
0
// Cancel button 
      tc = new TableCell(); 
      btnCancel = new Button(); 
      btnCancel.Text = "Cancel"; 
      btnCancel.Click += new EventHandler (btnCanel_Click) ; 
      tc.Controls.Add(btnCancel); 
      tr.Controls.Add(tc); 

      t.Controls.Add(tr); 


      // Empty table cell 
      tr = new TableRow(); 
      tc = new TableCell(); 
      tr.Controls.Add(tc); 

      this.Controls.Add(t); 
     } 

     protected void btnCanel_Click(object sender, EventArgs e) 
     { 

     } 

我現在要做的是。當我點擊取消按鈕時,它將我重定向到「Example.aspx」。 我使用C#重定向到新頁面當我點擊取消按鈕在C#(webpart)

回答

0

要做到你想要什麼,在服務器上,將Response.Redirect。雖然沒有必要回發。有幾個客戶端解決方案。使用LinkBut​​ton,w/onclick html屬性設置爲false。我的推薦是這樣的:

<INPUT TYPE="BUTTON" VALUE="Cancel" ONCLICK="window.location.href='http://www.yourdomain.com/example.aspx'"> 
1
protected void btnCanel_Click(object sender, EventArgs e) 
{ 
    Response.Redirect("example.aspx"); 
} 
+0

+1。我刪除了我的答案。 –

+0

Aww,你不必那樣做,它毀了我的笑話! ;) –

相關問題