在vs2005技术文档中看到这样一段代码:
<%@ Page Language="C#" MasterPageFile="~/master1.master" Title="Switchable Themes" StylesheetTheme="Blue" %>
<script runat="server">
public void Page_PreInit()
{
// Sets the Theme for the page.
this.Theme = "Blue";
if (Request.Form != null && Request.Form.Count > 0)
this.Theme = this.Request.Form[4].Trim();//对这句实在不太懂
}
</script><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1 id="title1">Switchable Themes on a Page</h1><br />
<h2 id="title2">Note how the master page content and the page content are affected</h2>
<p>Select a color from the drop-down list below to change the appearance of this page.</p>
<br /><br />
<asp:dropdownlist id="ddlThemes" runat="server" autopostback="true" >
<asp:listitem value="Blue">I'd like the page to be blue!</asp:listitem>
<asp:listitem value="Red">I'd like the page to be red!</asp:listitem>
<asp:listitem value="Green">I'd like the page to be green!</asp:listitem>
</asp:dropdownlist>
</asp:Content>
对其中的this.Theme = this.Request.Form[4].Trim();这句的4什么意思,有没有替代的方法达到同样的检索效果?谢谢各位高人
<%@ Page Language="C#" MasterPageFile="~/master1.master" Title="Switchable Themes" StylesheetTheme="Blue" %>
<script runat="server">
public void Page_PreInit()
{
// Sets the Theme for the page.
this.Theme = "Blue";
if (Request.Form != null && Request.Form.Count > 0)
this.Theme = this.Request.Form[4].Trim();//对这句实在不太懂
}
</script><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1 id="title1">Switchable Themes on a Page</h1><br />
<h2 id="title2">Note how the master page content and the page content are affected</h2>
<p>Select a color from the drop-down list below to change the appearance of this page.</p>
<br /><br />
<asp:dropdownlist id="ddlThemes" runat="server" autopostback="true" >
<asp:listitem value="Blue">I'd like the page to be blue!</asp:listitem>
<asp:listitem value="Red">I'd like the page to be red!</asp:listitem>
<asp:listitem value="Green">I'd like the page to be green!</asp:listitem>
</asp:dropdownlist>
</asp:Content>
对其中的this.Theme = this.Request.Form[4].Trim();这句的4什么意思,有没有替代的方法达到同样的检索效果?谢谢各位高人
获取上一页传递的参数可以写成Request.QueryString["name"]或者Request.Form["name"]//这name是上页传递的参数名称