我想根據5組單選按鈕的值創建一個查詢字符串。構建一個基於單選按鈕值的查詢字符串
選擇任何組是可選的,所以你可以選擇A組或B組。我將如何構建基於此的查詢字符串?我正在使用VB.NET 1.1
asp:Radiobuttonlist控件不喜歡空值,所以我訴諸正常的HTML單選按鈕。我的問題是我怎麼串起來選定的值到查詢字符串
我有這樣的事情現在:
HTML:
<input type="radio" name="apBoat" id="Apb1" value="1" /> detail1
<input type="radio" name="apBoat" id="Apb2" value="2" /> detail2
<input type="radio" name="cBoat" id="Cb1" value="1" /> detail1
<input type="radio" name="cBoat" id="Cb2" value="2" /> detail2
VB.NET
Public Sub btnSubmit_click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim queryString As String = "nextpage.aspx?"
Dim aBoat, bBoat, cBoat bas String
aBoat = "apb=" & Request("aBoat")
bBoat = "bBoat=" & Request("bBoat")
cBoat = "cBoat=" & Request("cBoat ")
queryString += aBoat & bBoat & cBoat
Response.Redirect(queryString)
End Sub
是這是構建查詢字符串的最佳方式,還是應該採用不同的方法?感謝我能得到的所有幫助。非常感謝。
請記住,包括System.Text如果你想使用StringBuilder。 – 2008-09-17 11:04:34