Selectable themes in ASP.NET
I have witteen this example in Visual Studio Express - it is from MS tuturial homepage, and I have checked that everything is written as it should, but get errormessage: line 9. Theme i开发者_JAVA技巧s not a valid themename
-Linje 9: this.Theme = this.Request.Form[4].Trim();
EXAMPLE
<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>
this.Request.Form[4].Trim()
This could be your problem. Have you determined the value you are referencing? You can reference form collections by name as well. Or use GetElementById(). Or use jQuery to cut more fat. Using a hard-coded 4 seems a error-prone. That element could change very easily. Use an ID and select on that.
精彩评论