ASP.NET中的可选主题

ASP.NET中的可选主题,asp.net,themes,Asp.net,Themes,我在Visual Studio Express中看到了这个示例-它来自MS tuturial主页,我检查了所有内容是否都按应有的方式编写,但收到错误消息: 第9行。主题不是有效的主题名 -Linje 9:this.Theme=this.Request.Form[4].Trim() 范例 <script runat="server"> public void Page_PreInit() { // Sets the Theme for the page.

我在Visual Studio Express中看到了这个示例-它来自MS tuturial主页,我检查了所有内容是否都按应有的方式编写,但收到错误消息: 第9行。主题不是有效的主题名

-Linje 9:this.Theme=this.Request.Form[4].Trim()

范例

<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>

公共无效页_PreInit()
{
//设置页面的主题。
this.Theme=“蓝色”;
如果(Request.Form!=null&&Request.Form.Count>0)
this.Theme=this.Request.Form[4].Trim();
} 
this.Request.Form[4].Trim()

这可能是你的问题。您是否已确定要引用的值?您还可以按名称引用表单集合。或者使用GetElementById()。或者使用jQuery来削减更多的脂肪。使用硬编码的4似乎容易出错。这种因素很容易改变。使用一个ID并选择该ID