0
我有一個返回空值的Request.QueryString有問題。我認爲這是從的OutputCacheASP.NET中的Request.QueryString和OutputCache
我在Default.aspx的(與主文件)
<%@ OutputCache Duration="60" VaryByParam="button" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e) {
TimeMsg.Text = DateTime.Now.ToString("G");
string v = Request.QueryString["button"];
PageName.Text = v;
}
</script>
<form method="get" action="Default.aspx">
<h5>Click a button</h5>
<input type="submit" name="button" value="One" />
<input type="submit" name="button" value="Two" />
<input type="submit" name="button" value="Three" />
</form>
<p>Page generated at : <asp:Label ID="TimeMsg" runat="server"></asp:Label></p>
<p>Page name : <asp:Label ID="PageName" runat="server"></asp:Label></p>
我再也不會寫<asp:Content ID='' ...></asp>
標籤。
當我按下其中一個按鈕時,PageName會返回空白,我用Debugger檢查了v
變量,我發現它返回null。
爲什麼?
是的,但獲取字符串將不會出現在URL中......它必須像'localhost/Default.aspx?buttonvalue = One'或類似的東西 –
是啊bcoz它把它當作post而不是得到 – Waqas
那麼,我想用GET方法做... –