Last post Oct 08, 2010 07:35 PM by jkirkerx
Feb 26, 2009 06:34 PM|jaikar|LINK
i am using a user control that has the html code with head tag is set to runat server. when i drop this control in main page, i am getting an error in the design time, Error rendering control, unhandled exception occured, request is not available in this
context, but at runtime, everything is working fine. i can fix this by removing the ID and runat=server in the head tag, but how to make this to work without removing the runat server for head tag ?.. which request it means that is not available.
i am very new to C#, i hope what i am asking makesence, apologize if i am not clear, i highly appreciate any explanation ! thankyou !...
here is the code present in the user control...
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="header.ascx.cs" Inherits="user_controls_header" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
unhandled exception occured
request is not available in the context
Mar 02, 2009 12:35 AM|Allen Chen – MSFT|LINK
Could you paste the code of aspx (Page) and ascx (your user control that causes this error)?
Oct 08, 2010 03:35 PM|belcherman|LINK
I am now having the exact same problem. I have setup sites with user controls since visual studio 2003 and this has never happend before until today. WTF is it that is causing this?
<%@ Register TagPrefix="NSC" TagName="RootHeader" src="UCrootHeader.ascx" %>
<!-- Begin Header -->
<NSC:RootHeader id="NSCRootHeader" runat="server"></NSC:RootHeader>
<!-- END Header -->
THe header user control contains regular stuff normally in a header control..
Oct 08, 2010 07:35 PM|jkirkerx|LINK
In design mode, the rendering engine is not capable of changing the head tag. Design mode is just a way for the programmer to check rendering in a limited way, and to set properties for server controls. So you have to remove the head tag code stuff from
the render side of your control.
Design mode should just be a copy of the control so you can preview it and set the properties.
You control should be laid out where you have OnInit to render in runtime, and something else to render in design mode. You have to fork out the control with 2 modes of operation.