2013-11-21 35 views
0

我想在一個按鈕單擊中將文本框的值顯示爲從一個網頁到另一個網頁的另一個文本框。 我知道Windows代碼但不知道Web應用程序。如何從asp.net中的另一個網頁訪問文本框的值

public qus as form = new question() 

qus.txtname=txtname.text 
+0

化妝使用會話或查詢字符串 –

回答

1

使用查詢字符串傳遞文本值到其他頁面的按鈕單擊處理程序,如:

Protected Sub Button1_Click(sender As Object, e As EventArgs) 
    Response.Redirect("OtherPage.aspx?textValue='Value from other page'") 
End Sub 

現在在另外一個頁面的Page_Load,拉出查詢字符串值並將其分配給該文本框,就像這樣:

Protected Sub Page_Load(sender As Object, e As EventArgs) 
    If Request.QueryString("textValue") IsNot Nothing Then 
     YourTextBox.Text = Request.QueryString("textValue").ToString() 
    End If 
End Sub 
2

在第一頁中添加按鈕單擊事件

Sub Btn_Click(sender As Object, _ 
         e As EventArgs) 

     Response.Redirect("SecondPage.aspx?id=" + txtname.text, false) 

End Sub  

在第二頁上設置頁面加載時的文本。

Private Sub Page_Load(sender As Object, e As EventArgs) 
    If Not IsPostBack 
     SecondPageTextBox.Text = Request.QueryString("textValue").ToString() 
    End If 
End Sub 
1

你必須第一頁

Protected Sub Button1_Click(sender As Object, e As EventArgs) 
    Response.Redirect("webpage2.aspx?textValue='value'") 
End Sub 

上編寫代碼在第二頁

Private Sub Page_Load(sender As Object, e As EventArgs) 
    If Not IsPostBack 
     SecondPageTextBox.Text = Request.QueryString("textValue").ToString() 
    End If 
End Sub 
相關問題